How to fix 'SDK client path is invalid' error in Thycotic Secret Server's API - python-3.x

I use Thycotic's Secret Server and am utilizing their API to query the password field of a secret. While using the API, I am receiving a SDK client path is invalid error.
Once I configured the connection (you only need to do it once according to the API documentation located at https://github.com/thycotic/secret-server-python), I then execute the query using:
from secret_server.sdk_client import SDK_Client
client = SDK_Client()
akey = client.commands.get_secret(1234, field='password').strip()
skey = client.commands.get_secret(4321, field='password').strip()
I expected to simply get my secrets when I print my akey and skey variables, but instead I get the error:
raise ValueError('SDK client path is invalid')
ValueError: SDK client path is invalid
What's interesting is that I have to run the configure command again to get it to work. I figure that's because when you actually go to configure the connection you specify the full path to your SDK client and you don't have to after you've already done it once.
Regardless, when I do, I get a machine is already initialized (as expected) response, and it then works. But you shouldn't have to do that. Plus, that would be an issue because the onboarding key will be stored in the code, and we can't have that.
Any suggestions?

I had a similar error; except I never got past the invalid SDK path.
I solved it by doing this:
Script A) init as outlined in the sdk documentation (only run once)
Script B)
client = SDK_Client()
client.config.SDK_CONFIG["path"] = path_to_my_sdk
key = client.commands.get_secret(1234, field = 'password')
Adding that middle line is what resolved the problem. I'll log this as an issue in the github that the init process apparently is not saving the path.

Related

BIM360 Issues editor Forge Node JS App -trying to run on localhost 3000

I am trying to work with the BIM 360 Issue Editor created by Petr and available on github https://github.com/petrbroz/bim360-issue-editor/tree/develop
I have added all the dependencies,etc. but seem to be stuck with the configuration.
I am testing on local host and I am getting invalid URI error, what would be the correct configuration variables for launch.json file for
"HOST_URL": "http://localhost:3000","SERVER_SESSION_SECRET","CLI_CONFIG_PASSWORD"
Also there is SENDGRID_API_KEY required, which throws an error on the console, I add the key from SendGrid in config.js, and the error goes away. Is it correct?
Please suggest. Thanks
Here's more details about the env. variables:
HOST_URL is just the host/port the app is listening on (for example, http://localhost:3000)
This value is used to built the callback URL for the 3-legged OAuth workflow; for example, if the host URL is http://localhost:3000, the callback URL will be http://localhost:3000/auth/callback
Note that the same callback URL must be configured for your Forge app on https://forge.autodesk.com/myapps
SERVER_SESSION_SECRET is an arbitrary string that will be used to encrypt/decrypt browser cookies
CLI_CONFIG_PASSWORD is only needed when you want to use the command-line utility that's part of the sample code; in that case the configuration for the CLI utility will be zipped in a password-protected *.zip file using this env. variable as the password
SENDGRID_API_KEY is also optional and only needed if you want the app to send email notifications to users who triggered the Excel export

fabric-sdk-node fails to retrieve the context of an existing user

I've got some problems while calling the function <async> getUserContext(name, checkPersistence), so far I know it fails only when I try to get the context of an existing user, but it does work with non existing users.
The code I use to create the client object and call the function is as follows:
const config = '-connection-profile-path';
const client = hfc.loadFromConfig(hfc.getConfigSetting(`network${config}`));
client.loadFromConfig(hfc.getConfigSetting(`${this.orgId}${config}`));
await client.initCredentialStores();
const admin = await client.getUserContext('admin', true);
And the error is:
[2019-10-04 11:41:38.701] [ERROR] utils/registerUser - TypeError:
Cannot read property 'curve' of undefined
which, as far as I know, makes no sense. The only solution I`ve found is to check if the certificates are up to date, that is deleting it and let runApp.sh & setupAPIs.sh (I'm using the balance-transfer example from hyperledger/fabric-samples) create the folder again with all those certificates.
I found that the only problem was that the users inside the docker container I was using were desynced with the ones in the State Store. So if you are using docker make sure to keep the users synchronized.

How do I get my deployed React.js app to use API secret keys? I'm using Heroku confing vars but still not working

Problem:
I created a simple React app (using Javascript and Node) that uses the GitHub API to search for users and return information about them. I need to use a GitHub oauth key so that I can make authenticated API requests. However, I am having trouble giving my deployed app (using Heroku) the key without hard-coding it into the API call. I'm fairly new at this so any help would be great! I linked the github repo at the bottom of this post.
I have tried several things which I will explain below:
Attempt 1:
I created a file where I set my GitHub key to a variable and exported it (Image of code)
I put said file in the .gitignore
I imported the variable in the files where I made API calls and used them it directly in the API call. (Image of API call)
This worked on my dev environment but (obviously) did not work on my deployed Heroku app because it had no idea what the variable was. (Image of error)
Attempt 2:
I configured variables in Heroku and set GITHUB_KEY to my key. (Image of Heroku variable setting).
Next, I checked that Heroku recognized this variable by running the command heroku config:get GITHUB_KEY and received the correct key in response (Image of terminal)
In my secrets file, I set the variable like so: process.env.GITHUB_KEY = 'a93b2c21918b42df5a28e0e529c627ee22c60de4'; (Image of setting variable using process.env)
And then I use it in my API calls on the frontend: const res = await fetch(
'https://api.github.com/users/${this.state.input}?access_token=${process.env.GITHUB_KEY}'
);.
However, I get the following error: SearchBar.js:32 GET https://api.github.com/users/livmarx?access_token=undefined 401 (Unauthorized). (Image of error).
So, I know that I'm misunderstanding how process.env works but cannot seem to figure it out! Any clarification would be super helpful.
Here is the link to my github repo: https://github.com/livmarx/zilliow-challenge

SendGrid API Key is not working. "The provided authorization grant is invalid, expired or revoked"

SendGrid seems to be preventing my node js server from sending emails.
I get this error message in the response on sending off an email:
The provided authorization grant is invalid, expired or revoked
I have an API key setup as well and have followed the documentation.
You need to use the API KEY GENERATED
DO NOT USE the API KEY ID
Sendgrid only displays the generated key once when you create it.
If you didn't record it somewhere when you created the key you'll need to create a new key and then you'll probably want to delete the old key since it would be useless if you don't know what it is.
FYI: The API key in the screenshot above is already deleted. I deleted it right away so please don't worry about me leaking that key.
This is a late answer and JAVA oriented.. But I simply copied the docs and didn't notice..
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
I just put my key in there and didn't see the getEnv. Silly of course.. but when trying to get things to work quickly...
For me I just had to generate a new API key. For some weird reason the former API key has become invalid, so I also added an alert for this case
In Sendgrid v3, I had the similar issue when using env variable in Node JS. If I use env variable, I get the above issue. But if I drop the string into the require process, it works.
Doesn't Work:
SENDGRID_API_KEY=SG.XXXXXXXXXXXXXXXXXXX
var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
Works
var sg = require('sendgrid')('SG.XXXXXXXXXXXXXXXXXXX');
Replace SG.XXXXXXXXXXXXXXXXXXX with API Key Generated (which you can only see once during key generation).
EDIT
Note : Make sure you don't save this to public repository. If you do anyone can use your API Key and also your account will be suspended by Sendgrid team temporarily until you remove it from repository.
In my case I was trying to debug the connection by using telnet and kept getting rejected.
Turns out that these two are not equivalent, echo will include \n in the encoded string.
echo 'apikey' | base64
printf 'apikey' | base64
So yeah, make sure you don't include the newline in the API key.
If you are using node js,
make sure you have the require('dotenv').config()line inside the file that needs the sendgrid/nodemailer module.
Without it, the sendgrid transporter will have an undefined value instead of the api_key.
Here's my solution:
Install the dotenv package: npm i dotenv
Go to the earliest entry point of your application(i.e index.js) and put this at the top:
const dotenv = require('dotenv').config();
Create a .env file and add SENDGRID_API_KEY=<YOUR_API_KEY>. NO quotes '' or "".
In your file which you use sendgrid, add this to the top:
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
Done.
It might be late for an answer but for people who are getting the same problem in spring boot
it might be caused at initialization when you are using env or property value
i was initializing the variable in the constructor before the value was loaded by spring and it was giving the same output. so either initialize it in the method you are calling the SendGrid function or do it after values are loaded
Instead of using,
api_key: ${process.env.SENDGRIDAPIKEY}
try,
api_key: "" + ${process.env.SENDGRIDAPIKEY} + ""
worked for me,
For me; I've just created a new API key and then it works again.
I'm %100 sure it was working with no any code change.
Maybe it is an issue with SendGrid or some sort of security action from SendGrid.
I had the same issue, it disappeared after I verified my email address and enabled 2FA.

How can I access the parameters of a service on a Carbon server in plain txt

What I've done is broken the default 'Version' service on my WSO2 DSS, I tried to set the Scopes variable for WS-Discovery and didn't put a closing tag/element when creating the parameter.
Now when I try to access the parameters screen I get an xml Parse error
TID: [0] [WSO2 Data Services Server] [2012-08-22 12:38:04,404] ERROR {org.wso2.carbon.service.mgt.ServiceAdmin} - Error occured while getting parameters of service : Version
{org.wso2.carbon.service.mgt.ServiceAdmin}org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '<' (code 60) in end tag Expected '>'. at [row,col {unknown-source}]: [2,58] at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296) at
I'm assuming this is stored in the H2 database, I've tried looking for the parameter in the .db file using notepad but I can't find it.
Is there another way to connect/browse the H2 db?
I've scanned through the repository, database and conf directories for clues without success.
UPDATE:
Yes you can connect to the H2 db using the included database Explorer under the Tools menu.
Use the connection details found in the repository/conf/registry.xml file
Then you can do SQL queries on it - (I haven't found the answer yet though)
UPDATE 2:
I don't think the parameters are held in the H2 db, but I managed to fix my problem by:
downloading the Version.aar file using the link on the list services page
deleting the Version service
Copying the Version.aar file into the repository/deployment/server/axis2services dir
I guess deleting the service removed any records/references to my broken parameter
I believe you've tried setting service parameters via the UI? Usually the service parameters you specify via the UI do not get saved in the services.xml of the original axis2 service archive. Instead, they get saved in the registry that is shipped with DSS and get applied to the service at runtime. But if you specify a malformed parameter then wouldn't be saved in the registry instead, throwing an exception while trying to engage that parameter. So there'll be no record saved corresponding to that kind of malformed parameters.
Hope this helps!
Cheers,
Prabath

Resources