class Doorkeeper::OAuth::Authorization::Code
Attributes
pre_auth[R]
resource_owner[R]
token[R]
Public Class Methods
new(pre_auth, resource_owner)
click to toggle source
# File lib/doorkeeper/oauth/authorization/code.rb, line 9 def initialize(pre_auth, resource_owner) @pre_auth = pre_auth @resource_owner = resource_owner end
Public Instance Methods
access_grant?()
click to toggle source
# File lib/doorkeeper/oauth/authorization/code.rb, line 24 def access_grant? true end
issue_token!()
click to toggle source
# File lib/doorkeeper/oauth/authorization/code.rb, line 14 def issue_token! return @token if defined?(@token) @token = Doorkeeper.config.access_grant_model.create!(access_grant_attributes) end
oob_redirect()
click to toggle source
# File lib/doorkeeper/oauth/authorization/code.rb, line 20 def oob_redirect { action: :show, code: token.plaintext_token } end
Private Instance Methods
access_grant_attributes()
click to toggle source
# File lib/doorkeeper/oauth/authorization/code.rb, line 34 def access_grant_attributes attributes = { application_id: pre_auth.client.id, expires_in: authorization_code_expires_in, redirect_uri: pre_auth.redirect_uri, scopes: pre_auth.scopes.to_s, } if Doorkeeper.config.polymorphic_resource_owner? attributes[:resource_owner] = resource_owner else attributes[:resource_owner_id] = resource_owner.id end pkce_attributes.merge(attributes).merge(custom_attributes) end
custom_attributes()
click to toggle source
# File lib/doorkeeper/oauth/authorization/code.rb, line 51 def custom_attributes # Custom access token attributes are saved into the access grant, # and then included in subsequently generated access tokens. @pre_auth.custom_access_token_attributes.to_h.with_indifferent_access end
pkce_attributes()
click to toggle source
# File lib/doorkeeper/oauth/authorization/code.rb, line 57 def pkce_attributes return {} unless pkce_supported? { code_challenge: pre_auth.code_challenge, code_challenge_method: pre_auth.code_challenge_method, } end
pkce_supported?()
click to toggle source
Ensures firstly, if migration with additional PKCE columns was generated and migrated
# File lib/doorkeeper/oauth/authorization/code.rb, line 68 def pkce_supported? Doorkeeper.config.access_grant_model.pkce_supported? end