Repository navigation
Enable OAuth PKCE Extension - #31129
Conversation
…r Metadata response
oneiros
left a comment
There was a problem hiding this comment.
I have one remark about spec types, but otherwise this is already looking very good. Thanks for your help with this!
|
First, to make sure I understand exactly the context, as I'm not so familiar with Doorkeepr and OAuth:
Please correct me if I'm wrong on any on this. (Now I'll look at the code itself and especially where you tagged me) |
It was originally for public clients, but is now a MUST for all clients due to authorization code injection attacks.
tl;dr; let's disregard refresh tokens for now, and focus on PKCE. (#27948 has been made a draft to indicate it should not be in 4.3) Doorkeeper's refresh token model is fundamentally broken though, because it doesn't keep trust chains (basically if you revoke the access token the refresh token can remain valid, and if you do a From Auth0:
tl;dr; is that you should actually have a separate oauth_refresh_tokens table, instead of just a column in the oauth_access_tokens table, as you need to be able to follow the chain of tokens.
Yeah, this is something I want to bring support for, but it's "complicated" — I need to fully review the implications of this, but work is started in #30329 |
|
@ClearlyClaire @oneiros also, on "public clients", I'm not sure if it actually makes long-term sense to continue support for (Note: Client ID Metadata Documents are currently an I-D and have been put in front of the IETF OAuth working group at IETF 120 this week, where overall they were well received. There's also further considerations around public clients vs confidential, which requires things like prohibiting certain grant flows for certain clients. There's also the question of whether |
|
Added an issue about Client ID Metadata Documents here: #31151 |
Reference PR: mastodon/mastodon#31129
This pull request partially supersedes #30329, in that I've separated out the PKCE changes from the other changes.
As per OAuth 2.0 Security Best Current Practices, we MUST support PKCE.
Whilst PKCE is recommended for all applications to use, forcing PKCE usage is a breaking change, so for now we do not force PKCE usage, only support it. PKCE is an important security mechanism for preventing OAuth Authorization Code Injection Attacks. Note: OAuth 2.1 requires the usage of PKCE.
In accordance with best practices, we only support S256, and explicitly do not support plain for PKCE
code_challenge_method. Unfortunately, Doorkeeper does not support a setting for whichcode_challenge_methods are supported, hence adding aOauthPreAuthorizationExtensionmodule and changing thedoorkeeper.errors.messages.invalid_code_challenge_methodvalue.I've also attempted to add some better tests to ensure certain elements are definitely present on the page, such that we're not just relying on the
response.bodycontaining a given string, but actually that the element exists.Fixes: #21913