Rr3khan/support personal token env auth - #116
Draft
rr3khan wants to merge 2 commits into
Draft
Conversation
Adds GetSessionConfigFromEnv, which builds an unpersisted session from the APONO_PERSONAL_TOKEN environment variable, with APONO_API_URL as an optional endpoint override for non-production tenants. Returns nil when the token variable is unset, so existing config-file behavior is unaffected.
CreateClient now resolves its session with explicit precedence: an explicit --profile flag wins, then a token from the environment, then the persisted config. This lets secret managers (e.g. 1Password Shell Plugins) authenticate every command per-invocation without a prior `apono login` and without the token being written to disk. Behaviour is unchanged when the environment variable is not set.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This enables secret managers to authenticate the Apono CLI per-invocation, without a prior
apono loginand without the token ever being written to disk.The concrete consumer is 1Password Shell Plugins: 1Password/shell-plugins#625 adds an Apono plugin that stores the personal API token in 1Password. Today the CLI's only token entry point is
apono login --personal-token, which persists the token in plaintext inconfig.json. With this change, a credential manager (or CI job) can injectAPONO_PERSONAL_TOKENinto the environment of each command instead, and the token never touches disk — which also lets the shell plugin cover everyaponocommand with biometric unlock, the same UX as the AWS/GitHub/etc. plugins.What this does
pkg/config: addsGetSessionConfigFromEnv(), which builds an unpersistedSessionConfigfromAPONO_PERSONAL_TOKEN.APONO_API_URLoptionally overrides the API endpoint for non-production tenants (defaults tohttps://api.apono.io).pkg/aponoapi:CreateClientresolves its session with explicit precedence:--profileflag (unchanged behavior),The env-var session reuses the existing
HTTPClientWithPersonalTokenbearer transport; nothing downstream changes.Session.AccountID/UserIDare empty in this mode — they're only populated at login time today and nothing outside the login flow reads them (account context at runtime comes from theGetUserSessionAPI, which works with a bearer token).What doesn't change
APONO_PERSONAL_TOKENis unset.--profileflag still always wins, so profile-pinned invocations (e.g. the access-details URI handler) are unaffected.apono login/logout/profilesare untouched.Testing
t.Setenv).go test -race ./...passes.$HOME:Error: no profiles configured, run 'apono login' to create a profile(unchanged)APONO_PERSONAL_TOKENset → the profile requirement is bypassed and the CLI makes an authenticated API call (verified end-to-end againstapi.apono.io)Open questions for maintainers