platformsh / legacy-cli

This is the legacy version of Platform.sh's command-line interface. The new version is at: https://github.com/platformsh/cli
https://docs.platform.sh/administration/cli.html
MIT License
224 stars 121 forks source link

PLATFORMSH_CLI_TOKEN per project #907

Open gormus opened 4 years ago

gormus commented 4 years ago

I'm managing projects from multiple Platform.sh accounts. Each time I need to switch to projects from another account, I have to logout from the CLI, and log back again with the account I need for that project.

One potential solution I can think of using the CLI tokens per project to authenticate them, without really logging out.

Could PLATFORMSH_CLI_TOKEN be defined per project and used for such scenario? Or is there already a working solution for such issue?

Thanks, Osman

pjcdawkins commented 4 years ago

That's an interesting use case.

If you're logged in without tokens, there is something else you can use, which is the PLATFORMSH_CLI_SESSION_ID variable. This namespaces your login session. The default value is default, but you could use this one-liner inside any Git repository to set it to that repository's path:

export PLATFORMSH_CLI_SESSION_ID="$(git rev-parse --show-toplevel)"

Each time you wanted to switch between sessions, you would cd path/to/repo and then run the above command. You can then log in normally, and it'll keep your session for next time. Does that help?