Repository navigation
Read HTTP auth from environment variables - #28
Merged
Merged
Conversation
…variables Tokens passed with --header end up on the command line. The new flags take the name of an environment variable instead, and the CLI reads the value from the environment. Later sources win for the same header name: --header, then --header-env, then --bearer-env. A missing or empty variable is a usage error that names the variable, not the value. The GitHub Action and the Azure Pipelines template get matching inputs that pass the variable names.
Move the 401 wording change into Changed. Document the Action workflow that passes only a variable name, the matching Azure Pipelines parameters, and that variable names follow the operating system's case rules. Tests now assert exit 2 and no leaked values for an empty or missing variable, keep tokens out of stdout, and cover --header-env overriding a typed --header.
# Conflicts: # CHANGELOG.md # README.md
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.
Read HTTP auth from environment variables
Right now the only way to authenticate an HTTP server is
--header "Authorization: Bearer $TOKEN". That puts the token on the command line, so it can end up in shell history or CI logs.This adds two flags that take the name of an environment variable instead of the token:
--bearer-env <VAR>sendsAuthorization: Bearer <value>, where<value>comes fromVAR. If the value already starts withBearer, it isn't added twice.--header-env 'Name: VAR'sends any header with the value ofVAR. Repeatable.Both only work with
--http. If the same header is set more than once, the order is--header, then--header-env, then--bearer-env, and the last one wins. A missing or empty variable is a usage error (exit 2) that names the variable, never the value.A 401 now says
The credentials were rejected.instead ofThe credentials in --header were rejected., and the hint for a missing token also mentions--bearer-env.The GitHub Action gets
bearer-envandheader-envinputs, and the Azure Pipelines template getsbearerEnvandheaderEnv. They pass the variable names to the CLI. Put the token in the step'senvfrom a secret:These inputs need a CLI that has the new flags. The wrapper fails fast if the installed CLI doesn't.
No OAuth flow in this PR.