Enable OAuth PKCE Extension (#31129)

This commit is contained in:
Emelia Smith 2024-07-26 10:53:10 +02:00 committed by GitHub
commit 693d9b03ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 164 additions and 6 deletions

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
module OauthPreAuthorizationExtension
extend ActiveSupport::Concern
included do
validate :code_challenge_method_s256, error: Doorkeeper::Errors::InvalidCodeChallengeMethod
end
def validate_code_challenge_method_s256
code_challenge.blank? || code_challenge_method == 'S256'
end
end

View file

@ -7,6 +7,7 @@ class OauthMetadataPresenter < ActiveModelSerializers::Model
:revocation_endpoint, :scopes_supported,
:response_types_supported, :response_modes_supported,
:grant_types_supported, :token_endpoint_auth_methods_supported,
:code_challenge_methods_supported,
:service_documentation, :app_registration_endpoint
def issuer
@ -59,6 +60,10 @@ class OauthMetadataPresenter < ActiveModelSerializers::Model
%w(client_secret_basic client_secret_post)
end
def code_challenge_methods_supported
%w(S256)
end
private
def doorkeeper

View file

@ -5,5 +5,6 @@ class OauthMetadataSerializer < ActiveModel::Serializer
:revocation_endpoint, :scopes_supported,
:response_types_supported, :response_modes_supported,
:grant_types_supported, :token_endpoint_auth_methods_supported,
:code_challenge_methods_supported,
:service_documentation, :app_registration_endpoint
end

View file

@ -26,6 +26,8 @@
value: @pre_auth.client.uid
= form.hidden_field :redirect_uri,
value: @pre_auth.redirect_uri
= form.hidden_field :code_challenge, value: @pre_auth.code_challenge
= form.hidden_field :code_challenge_method, value: @pre_auth.code_challenge_method
= form.hidden_field :state,
value: @pre_auth.state
= form.hidden_field :response_type,
@ -40,6 +42,8 @@
value: @pre_auth.client.uid
= form.hidden_field :redirect_uri,
value: @pre_auth.redirect_uri
= form.hidden_field :code_challenge, value: @pre_auth.code_challenge
= form.hidden_field :code_challenge_method, value: @pre_auth.code_challenge_method
= form.hidden_field :state,
value: @pre_auth.state
= form.hidden_field :response_type,