1

I am working on SalesforceDx and I have to authorize my devhub by just using Username of the org I dont want to enter password.

I have tried JWT token for authorization but it uses an OPEN SSl certificate and we have to specify local server key path in SFDX:JWT command, so it is necessary to store file path for server key either local or on server.

But I dont have to include such server key as path saved is exposed to other either it is local or on server

Can anyone have idea If we can authorize dev org only with username by combining any other task

  • 2
    JWT is the typical solution. Can you clarify (by editing your question) why it doesn't work for you? – David Reed Apr 18 at 12:38
  • JWT token is working but it required a digital signature for authorization , I want to any other solution for which no local paths are required – Hussain Gadisaaz Apr 19 at 13:37
  • Why? What context are you operating in (local machine, CI ...)? What is the source of this constraint about local paths? Please edit your question to clarify. – David Reed Apr 19 at 14:09
1

You should be using JWT authentication to your Dev Hub in a continuous integration context. That's exactly the use case it is intended for, and there is not a suitable alternative that provides the same security profile.

The path to the key file that you supply to sfdx force:auth:jwt:grant is the path to the key file in the container environment on your server; the key file itself is stored in encrypted form in your repository and then decrypted during the CI process. The path on your local machine is irrelevant because you only refer to paths on the server environment in your CI setup.

Here is an example from one of my projects of how this works on CircleCI. Note that the encrypted key file is stored in the Git repo as assets/server.key.enc, and the encryption passphrase is stored in the CI environment variable $KEY. Your desired username is stored in the CI variable $USERNAME and the consumer key of your connected app in $CONSUMERKEY.

openssl aes-256-cbc -k $KEY -in assets/server.key.enc -out assets/server.key -d -md sha256
sfdx force:auth:jwt:grant --clientid $CONSUMERKEY --jwtkeyfile assets/server.key --username $USERNAME --setdefaultdevhubusername -a DevHub

Note that we decrypt the file stored under version control in assets to a specific location we specify, assets/server.key. That is then the path we supply to sfdx force:auth:jwt:grant.

There is some complexity here, but the setup and overall flow is very well documented. I strongly encourage you to read Authorize an Org Using the JWT-Based Flow from the Salesforce DX Developer Guide, along with all of the linked documentation from that page, and the relevant Trailhead module (which uses TravisCI).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.