-
Notifications
You must be signed in to change notification settings - Fork 385
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
MSC2964: Usage of OAuth 2.0 authorization code grant and refresh token grant #2964
base: main
Are you sure you want to change the base?
Conversation
Related issue: matrix-org/matrix-spec#636 Related MSCs: #2965, #2966, #2967 In this MSC, there are a few areas that still need work. First, it outlines different profiles of clients. One important client type that is not yet covered by it are CLI tools. Second, there are the parts that we enforce. Third there is device handling in general. MSC2967 talks a bit about this, but there will definitely be some changes to the device API. |
proposals/2964-oauth2-profile.md
Outdated
Whenever the client ask for a token (either with a refresh token or by initiating a authorization code flow) the authentication server returns the list of scopes for which the token is valid. | ||
This helps client track what scopes they currently have access to, and let them upgrade temporarily a token with additional scopes to perform privileged actions. | ||
The authorization server can also downgrade the scopes of a session after a certain time by returning a reduced list of scopes when refreshing the token. | ||
The scope definitions are out of scope of this MSC and are defined in [MSC2967](/~https://github.com/matrix-org/matrix-doc/pull/2967). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be replaced with; the client requesting for a seperate token with only the required scope to perform this action, only for it to be dropped (deactivated) immidiately after?
Something about upgrading the same token doesn't sit well with me from a security perspective, it might be a deliberately locked-down token, and/or multiple actions at once could race to upgrade/downgrade the current token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a separate token purely for one scope / set of scopes sounds like a really good idea, especially for race condition reasons. Races could be also avoided by introducing state on AS/OP side, but that is quite out of scope of oauth2 specification (if I'm not mistaken)
At the same time, it would make specification compatible with more possible OP implementations.
Making it single use would be easily doable using jti claim on that token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that we no longer attempt to provide a replacement for UIA, so this thread is probably outdated too. @sandhose could you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We gave alternatives to all of the operations currently protected by UIA with a deeplink to the account management UI through MSC4191
Longterm, the idea is to:
- define scopes for specific actions
- define a way to step-up authentication, temporarily or not
But for the sake of simplicity, this isn't in part of the proposal
Co-authored-by: Dominik Henneke <dominik.henneke@nordeck.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpicky things things I noticed while reading through the updated version and suggested fixes
|
||
grant_type=authorization_code | ||
&code=iuB7Eiz9heengah1joh2ioy9ahChuP6R | ||
&redirect_uri=https://app.example.com/oauth2-callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&redirect_uri=https://app.example.com/oauth2-callback | |
&redirect_uri=https%3A%2F%2Fapp.example.com%2Foauth2-callback |
URL encoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this is done for readability
redirect_uri = https://app.example.com/oauth2-callback & | ||
scope = urn:matrix:client:api:* urn:matrix:client:device:AAABBBCCCDDD & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redirect_uri = https://app.example.com/oauth2-callback & | |
scope = urn:matrix:client:api:* urn:matrix:client:device:AAABBBCCCDDD & | |
redirect_uri = https%3A%2F%2Fapp.example.com%2Foauth2-callback & | |
scope = urn%3Amatrix%3Aclient%3Aapi%3A*+urn%3Amatrix%3Aclient%3Adevice%3AAAABBBCCCDDD & |
These values would be URL encoded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept this part simplified with no URL-encoding and extra spaces. It might be worth saying that, and give the actual url-encoded, with no space added URL in addition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values are already listed above in their non-url-encoded format. The oauth specs also include line breaks in their examples but url-encode the values
Co-authored-by: Tonkku <tonkku.kallio3@gmail.com>
e25fd17
to
c57be5e
Compare
|
||
#### Authorization request | ||
|
||
It then constructs the authorization request URL using the `authorization_endpoint` value, with the following query parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OAuth also has Pushed Authorization Requests which attempt to alleviate some of the issues of query parameters (see e.g. the introduction of RFC9126). I wonder if it'd be worth to consider these from the outset here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point, although because most Matrix clients will be public clients, we wouldn't really gain from the cryptographic integrity or confidentiality advantages PAR gives us. It would help us in two other ways though:
- validating the authorisation request earlier, to possibly show a user-friendly error within the client
- large authorisation requests, if we start having fine-grained authorisations
This is why for now, I'd prefer leaving them out of the proposal for the sake of simplicity, and introduce them later (probably alongside RAR) when we actually need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense and sounds fair to me. 👍
Rendered
Related: matrix-org/matrix-spec#636
Status:
Part of the following proposal:
Implementations:
Homeservers
Clients
In OIDC-native mode: