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

Support RFC8693: Token Exchange #1218

Open
adaniline opened this issue Dec 8, 2018 · 35 comments
Open

Support RFC8693: Token Exchange #1218

adaniline opened this issue Dec 8, 2018 · 35 comments
Labels
feat New feature or request. help wanted We are looking for help on this one.
Milestone

Comments

@adaniline
Copy link

adaniline commented Dec 8, 2018

In a zero trust microservices architecture, it is extremely useful to have an ability to generate "on behalf of" access tokens with shorter lifespan and narrower scope when performing service to service calls.
Even though OAuth 2.0 Token Exchange (https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16) is a draft right now, it would be extremely useful if Hydra supported a way to exchange an access token with an "on behalf of" token.

Describe the solution you'd like
Standard-based:

Proprietary:

@aeneasr
Copy link
Member

aeneasr commented Dec 8, 2018

While it looks like a reasonable approach, there are so many different grant extensions to the existing OAuth2 protocol in draft (or self-defined by e.g. Google) that we simply lack the resources to implement and maintain them, which is why drafts are generally not being implemented.

In my personal view, I'm not a fan of using OAuth2, a framework that was initiated to give 3rd party developers a way to access personal information, for things like workload/service auth. I think systems like SPIFFE take a much more sane approach to this. We are actually working with Scytale, co-founded by Evan Gilman (he wrote the Book Zero Trust Networks), to deliver a way to solve workload auth in the context of OAuth2. But this will (obviously) take a while.

Closing this, for now, as a wontfix/wontdo. Feel free to keep the conversation going though.

@aeneasr aeneasr closed this as completed Dec 8, 2018
@aberasarte
Copy link
Contributor

Sorry @aeneasr for writing in this closed issue but I'm just wondering if you could give more details regarding this statement:

In my personal view, I'm not a fan of using OAuth2, a framework that was initiated to give 3rd party developers a way to access personal information, for things like workload/service auth

We are already using Hydra and OIDC for user authentication and we are planning to use it for authorizing third party applications using the client_credentials grant. I thought that was the right approach and it would simplify our backend authn/authz infrastructure but maybe I'm missing something here?

@aeneasr
Copy link
Member

aeneasr commented Jun 27, 2019

You can use client_credentials if you want to. The proposed draft above is something completely different.

@aberasarte
Copy link
Contributor

OK, I misunderstood your sentence then. Thanks for the clarification!

@smeir
Copy link

smeir commented Mar 23, 2020

Hi @aeneasr
Since January 2020 the OAuth 2.0 token exchange grant type specification is not a draft any more.

In our projects we use Hydra as authorisation server and for some use cases we will need a token exchange.
Are there any plans to implement this extension grant type or is there any documentation on how to do it by ourself?

@aeneasr
Copy link
Member

aeneasr commented Mar 23, 2020

We currently lack use cases / popular demand and resources to tackle this, but do welcome contributions. As a word of caution, this will be a lot of work to implement!

@0ka
Copy link

0ka commented Apr 20, 2020

Hi @aeneasr
We would like to thrive this topic forward with a contribution. Digging through the source code some points are pretty clear. But we would like to have a talk before starting this to get the right direction/architecture decisions.

@aeneasr
Copy link
Member

aeneasr commented Apr 20, 2020

Sounds good! I'll reopen that - for clarification, this will be about implementing https://tools.ietf.org/html/rfc8693 right?

@aeneasr aeneasr reopened this Apr 20, 2020
@aeneasr aeneasr changed the title Implement "on behalf of" flow / token exchange Implement RFC8693 Apr 20, 2020
@aeneasr aeneasr added feat New feature or request. help wanted We are looking for help on this one. labels Apr 20, 2020
@aeneasr aeneasr added this to the unplanned milestone Apr 20, 2020
@0ka
Copy link

0ka commented May 5, 2020

Yes that is RFC8693.
We would create a new handler/oauth2/flow_token_exchange.go in the fosite project. Do we need an own issue in fosite or is this issue here sufficient?

@aeneasr
Copy link
Member

aeneasr commented May 14, 2020

Sorry, I overlooked your comment. Yes - no need to create another issue!

@mpnunes
Copy link

mpnunes commented Jun 22, 2020

Our use case:
We have three applications A, B, and C.
User U grants application A access to B and C with auth code grant. Offline access should also work, means that A will get a refresh token.
Now application A accesses application B and B accesses application C (in the name of user U), allways with offline access. Here we need the token exchange (A uses its token to access B in the name of U, B exchanges the token to get an own access and refresh tokens to access C in the name of U). This chain of delegation could of course be longer (D, E, ...).

Implementation idea:

  • New flow_token_exchnage.go in fosite
  • Clients that have grant type "urn:ietf:params:oauth:grant-type:token-exchange" are allowed to ask for token exchange
  • Request for token_exchange is similar to client_cresentials request with additional parameters as per RFC8693 (e.g. "subject_token", "subject_token_type")

Permission checks
Option 1:

  • Clients have an additional claim "may_act" with a list of all IDs of the clients that should be allowed to exchange tokens. Tokens/request from the cient than contains the "may_act" field. During processing of the token exchange fosite verify that the original token/request allows the exchange for the current client requesting the exchange. (Issue here is that the spec define only one may_act field and not a list, whould be needed for chained delegation)

Option 2:

  • On token-exchange hydra calls a configured callback similar to the consent app that allows to make checks externaly.

What's your opinion on that?

@aeneasr
Copy link
Member

aeneasr commented Jun 26, 2020

Thank you for your thoughts! I think that sounds reasonable! The idea of may_act is to restrict who can exchange an access token? So in your example, the client of C would have may_act: B?

Are there best practices around this? I do think that it might be tricky if every client is allowed to exchange token with one another so we probably need some type of restriction.

I think a callback wouldn't work that well because there is no user interaction (similar to client_credentials), so probably option 1 would be the way to go.

@mpnunes
Copy link

mpnunes commented Aug 22, 2020

Correct, the may_act claim specifies whether a client is allowed to exchange the token it has received in order to "act" has the original client (of the token it received).

So in the example before (and in answer to your question) the token of A should contain may_act claims for B and C (assuming C should keep offline access / get a refresh token), specifying that B and C can exchange the token sent by A.

The problem we have in this scenario is that rfc8693 only provides a brief example with a flat structure for may_act, e.g.:

"may_act" :
{
"sub": "B"
"iss": "..."
}

and what we need would rather be something like an array of multiple subjects e.g.:

"may_act" : [
{
"sub": "B"
"iss": "..."
}
{
"sub": "C"
"iss": "...""
}
...
]

in order to define a possible chain of delegation, or perhaps something simpler.
RFC 8693 is not so clear at this point. Quote:

"The may_act claim makes a statement that one party is authorized to become the actor and act
on behalf of another party. The claim might be used, for example, when a subject_token is
presented to the token endpoint in a token exchange request and may_act claim in the subject
token can be used by the authorization server to determine whether the client (or party
identified in the actor_token ) is authorized to engage in the requested delegation or
impersonation. The claim value is a JSON object, and members in the JSON object are claims that
identify the party that is asserted as being eligible to act for the party identified by the JWT
containing the claim."

I totally agree with you, not every client should be able to exchange any token it receives, therefore the importance of the "may_act" claim in the token to be exchanged.
Unfortunately I could not find any best practices on this subject.

After a longer discussion we came up with the use case that at some point, in the previously given scenario, user U may wish to revoke the a exchange grant it gave before to some application (e.g. application B or C). If we restrict the check to the may_act claim within the token to be exchanged, it would not be possible to revoke a previously issued token when this has e.g offline access, as the application could indefinitely refresh its token. Considering this, it would be enough to have this information within the client, at least for an first implementation, as a list of "clients" that are allowed to perform the exchange. So in the previous example, U gave exchange rights to applications B and C, B did an exchange and got an own refresh token, passes the token to C and C exchanges and gets an own refresh token. If at some point U remove the exchange permission to B, when using the refresh token again B would get an unauthorized. This would imply extending the refresh logic to check if the client refreshing the exchanged token still has the right to do so.

@github-actions
Copy link

I am marking this issue as stale as it has not received any engagement from the community or maintainers in over half a year. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • open a new issue with updated details and a plan on resolving the issue.

We are cleaning up issues every now and then, primarily to keep the 4000+ issues in our backlog in check and to prevent maintainer burnout. Burnout in open source maintainership is a widespread and serious issue. It can lead to severe personal and health issues as well as enabling catastrophic attack vectors.

Thank you for your understanding and to anyone who participated in the issue! 🙏✌️

If you feel strongly about this issues and have ideas on resolving it, please comment. Otherwise it will be closed in 30 days!

@github-actions github-actions bot added the stale Feedback from one or more authors is required to proceed. label Sep 21, 2021
@aeneasr
Copy link
Member

aeneasr commented Sep 21, 2021

Marked as stale in error.

@github-actions github-actions bot removed the stale Feedback from one or more authors is required to proceed. label Sep 22, 2021
@github-actions
Copy link

Hello contributors!

I am marking this issue as stale as it has not received any engagement from the community or maintainers a year. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

Throughout its lifetime, Ory has received over 10.000 issues and PRs. To sustain that growth, we need to prioritize and focus on issues that are important to the community. A good indication of importance, and thus priority, is activity on a topic.

Unfortunately, burnout has become a topic of concern amongst open-source projects.

It can lead to severe personal and health issues as well as opening catastrophic attack vectors.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone.

If this issue was marked as stale erroneous you can exempt it by adding the backlog label, assigning someone, or setting a milestone for it.

Thank you for your understanding and to anyone who participated in the conversation! And as written above, please do participate in the conversation if this topic is important to you!

Thank you 🙏✌️

@github-actions github-actions bot added the stale Feedback from one or more authors is required to proceed. label Sep 22, 2022
@thomasvargiu
Copy link

Hi, any news on this?

@github-actions github-actions bot removed the stale Feedback from one or more authors is required to proceed. label Oct 8, 2022
@drwatsno
Copy link
Contributor

https://datatracker.ietf.org/doc/html/rfc8693 declares new grant type "urn:ietf:params:oauth:grant-type:token-exchange". We tested hydra 2.0 for use with new grant type but without success. Also, we didn't found any configuration options for this flow or any code in codebase which is intended to support it

FYI @aeneasr

@rverma-dev
Copy link

Same here, we are also trying to use the same. Although same is implemented in Keycloak. We were very enthusiastically planning to migrate from keycloak but unfortunately got stuck here.

@ghenry
Copy link

ghenry commented Nov 27, 2022 via email

@alee792
Copy link

alee792 commented Nov 28, 2022

@ghenry, the release notes state that this RFC is implemented, but I can't seem to find any trace of it in the docs or codebase.

@ghenry
Copy link

ghenry commented Nov 28, 2022

Where are folks seeing this mentioned?

Nothing on the code base - https://github.com/ory/hydra/search?q=RFC8693

@ghenry
Copy link

ghenry commented Nov 28, 2022

@alee792
Copy link

alee792 commented Nov 28, 2022 via email

@alee792
Copy link

alee792 commented Nov 30, 2022

A low effort search to check if the IETF URN for exchange is used within Hydra or Fosite yields no results: https://github.com/search?l=&q=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange+repo%3Aory%2Fhydra+repo%3Aory%2Ffosite&type=code

@aeneasr, any chance we can get clarification and whether it's implemented or the release notes jumped the gun?

@mutexlock
Copy link

OAuth 2.0 Token Exchange (RFC8693) is now fully supported, including the JSON Web Token profile!

it seems only support rfc7523 @aeneasr

@aeneasr
Copy link
Member

aeneasr commented Dec 2, 2022

Yes, we messed up in here unfortunately. Can you help us identify all the places where the incorrect RFC is linked? We have to update it :)

@vinckr
Copy link
Member

vinckr commented May 23, 2023

Hello all,

have a look at this community project: https://github.com/Exact-Realty/ts-hydra-rfc8693

This will help you use OAuth2 Token Exchange until its implemented in Ory Hydra

@kmherrmann kmherrmann changed the title Implement RFC8693 Support RFC8693: Token Exchange Jun 21, 2023
Copy link

Hello contributors!

I am marking this issue as stale as it has not received any engagement from the community or maintainers for a year. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas on how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan for resolving the issue.

Throughout its lifetime, Ory has received over 10.000 issues and PRs. To sustain that growth, we need to prioritize and focus on issues that are important to the community. A good indication of importance, and thus priority, is activity on a topic.

Unfortunately, burnout has become a topic of concern amongst open-source projects.

It can lead to severe personal and health issues as well as opening catastrophic attack vectors.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone.

If this issue was marked as stale erroneously you can exempt it by adding the backlog label, assigning someone, or setting a milestone for it.

Thank you for your understanding and to anyone who participated in the conversation! And as written above, please do participate in the conversation if this topic is important to you!

Thank you 🙏✌️

@github-actions github-actions bot added the stale Feedback from one or more authors is required to proceed. label Jun 21, 2024
@etodanik
Copy link

etodanik commented Jun 21, 2024

Well, that's a bit of an unfair way to categorize it. This is one of the most commented open issues. The fact that people are respectfully not spamming it doesn't mean that it's not one of the more wanted issues right now. Also, for me this was literally THE deal breaker on whether I could use Ory on my last few projects.

@aeneasr
Copy link
Member

aeneasr commented Jun 21, 2024

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone.

If this issue was marked as stale erroneously you can exempt it by adding the backlog label, assigning someone, or setting a milestone for it.

@aeneasr aeneasr removed the stale Feedback from one or more authors is required to proceed. label Jun 21, 2024
@shadiramadan
Copy link

I also require this feature. In my use case I trust/verify a Google token in AppScript (for a looker studio connector) and want to exchange it for an access token for auth to my apis.

I’m shopping for auth solutions because I’m currently implementing oauth2 myself and that seemed like re-inventing the wheel. This use case is a dealbreaker though.

@ashish3805
Copy link

Eagerly Waiting, This is a deal breaker.

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

No branches or pull requests