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

Add token_prefixes #2845

Closed
4 of 6 tasks
ludydoo opened this issue Nov 9, 2021 · 6 comments
Closed
4 of 6 tasks

Add token_prefixes #2845

ludydoo opened this issue Nov 9, 2021 · 6 comments
Labels
feat New feature or request.
Milestone

Comments

@ludydoo
Copy link
Contributor

ludydoo commented Nov 9, 2021

Preflight checklist

Describe your problem

Hello there!

This is a feature request to enable adding prefixes to tokens that ory hydra generates, in order to distinguish the token type without having to call the introspection endpoint, and to keep access tokens opaque.

https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
https://api.slack.com/authentication/token-types
https://stripe.com/docs/api/authentication

Describe your ideal solution

An option in the configuration to specify the prefixes for each token type

token_prefixes:
  access_token:  acme:oac:
  id_token:      acme:oid:
  refresh_token: acme:orf:

Workarounds or alternatives

None that I could find, apart from modifying the source code

Version

Latest

Additional Context

The reason for this feature request is because we will need to generate other types of tokens than OAuth tokens. Our policy enforcement endpoint would need to verify the inbound request token.

For example, given these token types

  • oa: (oauth token issued by hydra)
  • or: (oauth refresh token issued by hydra)
  • oi: (oauth id token issued by hydra)
  • pat: (personal access token issued by my-pac-service)
  • mt: (machine token issued by my-admin-service)

The policy enforcement endpoint would need to distinguish which service to call for the token introspection.

If the tokens were prefixed, it would be very easy to call the appropriate service to verify the token. That could even be done eg. Envoy ext_authz, with a route matcher.

Sample logic

func VerifyAuthHeader(authorizationHeader string){
  if strings.HasPrefix(authorizationHeader, "Bearer oa:"){
    // call hydra admin token introspection 
  }
  if strings.HasPrefix(authorizationHeader, "Bearer pat:"){
    // call my-pac-service
  }
}
...
@ludydoo ludydoo added the feat New feature or request. label Nov 9, 2021
@ludydoo ludydoo changed the title Add tokens.prefix option Add token_prefixes Nov 9, 2021
@aeneasr
Copy link
Member

aeneasr commented Nov 9, 2021

Thank you for the idea! Please note that this will only work for opaque tokens, so when not using the JWT strategy. It will also not work for ID tokens!

But for refresh and access tokens this could work :)

@aeneasr aeneasr added this to the v2.0 milestone May 18, 2022
aeneasr added a commit to ory/fosite that referenced this issue Jun 17, 2022
aeneasr added a commit to ory/fosite that referenced this issue Jun 17, 2022
aeneasr added a commit to ory/fosite that referenced this issue Jun 17, 2022
aeneasr added a commit that referenced this issue Jun 17, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories.

Closes #2845
aeneasr added a commit that referenced this issue Jun 17, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
@aeneasr aeneasr mentioned this issue Jun 17, 2022
7 tasks
@aeneasr
Copy link
Member

aeneasr commented Jun 17, 2022

done in v2

@aeneasr aeneasr closed this as completed Jun 17, 2022
aeneasr added a commit that referenced this issue Jun 23, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Jun 23, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Jun 23, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Jun 23, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Jun 27, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
grantzvolsky pushed a commit that referenced this issue Aug 1, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Aug 1, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Aug 18, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Sep 5, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
aeneasr added a commit that referenced this issue Sep 7, 2022
This patch adds token prefixes to access tokens (`ory_at_`), refresh tokens (`ory_rt_`), and authorize codes (`ory_ac_`). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only issued for non-JWTs.

Closes #2845
@rdfirtal
Copy link

rdfirtal commented Nov 3, 2022

Will token prefixes become configurable like OP suggests?

@aeneasr
Copy link
Member

aeneasr commented Nov 4, 2022

no!

@NickUfer
Copy link
Contributor

What is the reason for not making these configurable except for everybody knowing ory hydra is used?

@aeneasr
Copy link
Member

aeneasr commented Jul 17, 2023

ory/fosite#733 (comment)

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

No branches or pull requests

4 participants