Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable sfdx auth:login:sfdx-url to read the url from stdin #2120

Closed
AllanOricil opened this issue May 9, 2023 · 24 comments · Fixed by salesforcecli/plugin-auth#886
Closed
Labels
feature Issue or pull request for a new feature

Comments

@AllanOricil
Copy link

AllanOricil commented May 9, 2023

Is your feature request related to a problem? Please describe.

no

What are you trying to do

I don't want to store a secret in disk as a plain text.

Describe the solution you'd like

sfdx could read the auth url from stdin like docker login does echo $PASSWORD | docker login --username foo --password-stdin. Where $PASSWORD is an env variable available in a single shell session. It isn't saved anywhere in disk as a plain text, also not loaded by ~/.profile, or rc files like ~/.bashrc,~/.zshrc

It could work like this

echo $AUTH_URL | sfdx auth:login:sfdx-url --sfdx-auth-url

or

sfdx auth:login:sfdx-url --sfdx-auth-url $AUTH_URL

Then you can delete the --sfdx-auth-url-file flag.

Describe alternatives you've considered

N/a

Additional context
N/A

@AllanOricil AllanOricil added the feature Issue or pull request for a new feature label May 9, 2023
@github-actions
Copy link

github-actions bot commented May 9, 2023

Thank you for filing this feature request. We appreciate your feedback and will review the feature at our next grooming or sprint planning session. We prioritize feature requests with more upvotes and comments.

@git2gus
Copy link

git2gus bot commented May 9, 2023

This issue has been linked to a new work item: W-13176733

@amtrack
Copy link

amtrack commented May 11, 2023

I'd love to see this natively supported as well.

@AllanOricil Until this is implemented you could use the following workaround on UNIX and MacOS:

sfdx auth sfdxurl store -d -a devhub -f <(echo "$SFDX_AUTH_URL_DEVHUB")

This is using Bash Process Substitution.

$ ls <(echo "hi ls")
/dev/fd/11
$ cat <(echo "hi cat")
hi cat

@AllanOricil
Copy link
Author

AllanOricil commented May 11, 2023

I dont think it would solve the problem because process substitution saves the information you piped in it to a file at /dev/fd/

When we use process substitution, the file location is echoed. This means its location can be retrieved from history if not deleted. I can consult the history, find the file, read its content. Even without knowing its location, I could just search for the Auth Url Pattern in all files at /dev/fd

@amtrack
Copy link

amtrack commented May 11, 2023

@AllanOricil As far as I know it isn't written to disk.

$ ls <(echo "hi ls")
/dev/fd/11
$ cat /dev/fd/11
cat: /dev/fd/11: Bad file descriptor

@AllanOricil
Copy link
Author

According to this guide,

Process substitution uses /dev/fd/<n> files to send the results of the process(es) within parentheses to another process

I tried to access them and it seems possible
image

@AllanOricil
Copy link
Author

AllanOricil commented May 11, 2023

@amtrack
Copy link

amtrack commented May 11, 2023

@AllanOricil Yes, I can reproduce your example.
But using exec 3<FILENAME isn't what I suggested :-)

Can you reproduce my example?

$ ls <(echo "hi ls")
/dev/fd/11
$ cat /dev/fd/11
cat: /dev/fd/11: Bad file descriptor

@AllanOricil
Copy link
Author

@amtrack I can confirm that /dev/fd/11 does not have any data in it. No idea why some of these files are readable and some are not. Kind weird.

image

I can """read""" it using the browser, but it displays nothing
image

the fs also shows that it has 0 bytes
image

do you know why the number 11 is a constant in your example? I thought n was the number of the shell process
why it does not store data like number 3 do?

@ImJohnMDaniel
Copy link

FWIW, I love this idea!!!!

@amtrack
Copy link

amtrack commented May 11, 2023

I'd definitely prefer having it implemented using a new --sfdx-auth-url flag just like @AllanOricil described it instead of documenting a workaround that unfortunately only works on UNIX and MacOS with Bash. 😄

@AllanOricil
Copy link
Author

AllanOricil commented May 12, 2023

the same problems could happen with the jwt flow which also reads a key from disk --jwt-key-file
just don't use this auth url in ci automations, create ur own connected app and rotate keys from time to time.

@AllanOricil AllanOricil changed the title enable sfdx auth:login:sfdx-url to read the url from memory enable sfdx auth:login:sfdx-url to read the url from stdin May 12, 2023
@AllanOricil AllanOricil reopened this May 12, 2023
@AllanOricil
Copy link
Author

reopened because I still think it does not make sense to read unencryted secrets from disk

@AllanOricil
Copy link
Author

doc still broken
image

@cristiand391
Copy link
Member

@AllanOricil thanks for the heads up!
We fixed the issue with templates not being rendered when generating the CLI command reference. IIRC, it take a few weeks to get those pages updated, I'll check again next week.

@AllanOricil AllanOricil reopened this May 26, 2023
@AllanOricil
Copy link
Author

Here there is an example of how this could be achieved
oclif/oclif#245

@AllanOricil
Copy link
Author

I opened a PR for this new flag

@WillieRuemmele
Copy link
Member

@AllanOricil
Copy link
Author

AllanOricil commented Dec 7, 2023

It can be implemented with oclif/core#894 once core is updated to v3

@shetzel
Copy link
Contributor

shetzel commented Jan 10, 2024

The fix is now in the sf CLI release candidate version, v2.24.4.

@AllanOricil
Copy link
Author

SmartSelect_20240110_184438_Brave.jpg

@AllanOricil
Copy link
Author

https://youtube.com/clip/Ugkxy3FFXYGwr5TnOfwiG2fZAJZEA7JZqAeg?feature=shared

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issue or pull request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants