Class: Doorkeeper::OAuth::PreAuthorization

Inherits:
Object
  • Object
show all
Includes:
Validations
Defined in:
lib/doorkeeper/oauth/pre_authorization.rb

Instance Attribute Summary collapse

Attributes included from Validations

#error

Instance Method Summary collapse

Methods included from Validations

#valid?, #validate

Constructor Details

#initialize(server, parameters = {}, resource_owner = nil) ⇒ PreAuthorization

Returns a new instance of PreAuthorization.



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 24

def initialize(server, parameters = {}, resource_owner = nil)
  @server = server
  @client_id = parameters[:client_id]
  @response_type = parameters[:response_type]
  @response_mode = parameters[:response_mode]
  @redirect_uri = parameters[:redirect_uri]
  @scope = parameters[:scope]
  @state = parameters[:state]
  @code_challenge = parameters[:code_challenge]
  @code_challenge_method = parameters[:code_challenge_method]
  @resource_owner = resource_owner
  @custom_access_token_attributes = parameters.slice(*Doorkeeper.config.custom_access_token_attributes).to_h
end

Instance Attribute Details

#authorization_response_flowObject (readonly)

Returns the value of attribute authorization_response_flow.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def authorization_response_flow
  @authorization_response_flow
end

#clientObject (readonly)

Returns the value of attribute client.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def client
  @client
end

#code_challengeObject (readonly)

Returns the value of attribute code_challenge.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def code_challenge
  @code_challenge
end

#code_challenge_methodObject (readonly)

Returns the value of attribute code_challenge_method.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def code_challenge_method
  @code_challenge_method
end

#custom_access_token_attributesObject (readonly)

Returns the value of attribute custom_access_token_attributes.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def custom_access_token_attributes
  @custom_access_token_attributes
end

#missing_paramObject (readonly)

Returns the value of attribute missing_param.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def missing_param
  @missing_param
end

#redirect_uriObject (readonly)

Returns the value of attribute redirect_uri.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def redirect_uri
  @redirect_uri
end

#resource_ownerObject (readonly)

Returns the value of attribute resource_owner.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def resource_owner
  @resource_owner
end

#response_modeObject (readonly)

Returns the value of attribute response_mode.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def response_mode
  @response_mode
end

#response_typeObject (readonly)

Returns the value of attribute response_type.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def response_type
  @response_type
end

#stateObject (readonly)

Returns the value of attribute state.



20
21
22
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 20

def state
  @state
end

Instance Method Details

#as_json(_options = nil) ⇒ Object



61
62
63
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 61

def as_json(_options = nil)
  pre_auth_hash
end

#authorizable?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 38

def authorizable?
  valid?
end

#error_responseObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 50

def error_response
  if error == Errors::InvalidRequest
    OAuth::InvalidRequestResponse.from_request(
      self,
      response_on_fragment: response_on_fragment?,
    )
  else
    OAuth::ErrorResponse.from_request(self, response_on_fragment: response_on_fragment?)
  end
end

#form_post_response?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 65

def form_post_response?
  response_mode == "form_post"
end

#scopeObject



46
47
48
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 46

def scope
  @scope.presence || (server.default_scopes.presence && build_scopes)
end

#scopesObject



42
43
44
# File 'lib/doorkeeper/oauth/pre_authorization.rb', line 42

def scopes
  Scopes.from_string(scope)
end