Skip to content

Commit 34573fb

Browse files
committed
Ignoring unrecognized custom attributes
1 parent 267e4c5 commit 34573fb

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/doorkeeper/oauth/authorization/code.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ def access_grant_attributes
5050

5151
def custom_attributes
5252
# Custom access token attributes are saved into the access grant,
53-
# and then included in subsequently generated access tokens.
54-
@pre_auth.custom_access_token_attributes.to_h.with_indifferent_access
53+
# and then included in subsequently generated access tokens. Only
54+
# recognized attributes are saved.
55+
@pre_auth.custom_access_token_attributes.to_h.with_indifferent_access.select do |attrib, _v|
56+
Doorkeeper.config.access_grant_model.has_attribute?(attrib)
57+
end
5558
end
5659

5760
def pkce_attributes

lib/doorkeeper/oauth/base_request.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def find_or_create_access_token(client, resource_owner, scopes, custom_attribute
3838
use_refresh_token: Authorization::Token.refresh_token_enabled?(server, context),
3939
}
4040

41+
# Only select custom attributes that the token model recognizes.
42+
custom_attributes.select! do |attrib, _v|
43+
Doorkeeper.config.access_token_model.has_attribute?(attrib)
44+
end
45+
4146
@access_token =
4247
Doorkeeper.config.access_token_model.find_or_create_for(**token_attributes.merge(custom_attributes))
4348
end

0 commit comments

Comments
 (0)