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

feat #4448: add support for JWT tokens #6609

Merged
merged 6 commits into from May 12, 2016
Merged

feat #4448: add support for JWT tokens #6609

merged 6 commits into from May 12, 2016

Conversation

dgnorton
Copy link
Contributor

@dgnorton dgnorton commented May 12, 2016

JWT token authentication

This PR adds JWT token authentication. This allows users to authenticate requests using only their user name and a JWT token signed with a shared key.

configuration

In the config file:

[http]
   shared-secret = "long pass phrase used for signing tokens"

requests

HTTP requests wishing to use JWT token authentication should:

  • create a token with the following required claims
    • username - user that is making the request
    • exp - token's expiration in Unix epoc
  • sign the token using the same shared secret in the config
  • add the signed token string to the HTTP Authorize header:
    • Bearer <signed token string blob>

security considerations / suggestions

  • Anyone with an unexpired token can execute any request the user specified in the username claim of the token has permission to execute.
  • Set reasonable token expirations
Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @gunnaraasen, @joelegasse and @e-dard to be potential reviewers

if u, p := q.Get("u"), q.Get("p"); u != "" && p != "" {
return u, p, nil
// Check for the HTTP Authorization header.
if s := r.Header.Get("Authorization"); s != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be X-Authorization

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about Authorization: Bearer ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, the Authorization header allows for custom schemes.

OAuth2 bearer tokens: https://tools.ietf.org/html/rfc6750#page-5

AWS scheme: http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#ConstructingTheAuthenticationHeader

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I didn't realize Authorization was a standard header these days. Typically when using custom headers, you always prepend them with X- first.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e-dard
Copy link
Contributor

e-dard commented May 12, 2016

Couple of nits but LGTM 👍

@retorquere
Copy link

Is there documentation on how to use this in InfluxDB?

@timhallinflux timhallinflux added this to the 1.0.0 milestone Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants