Class: OmniAuth::Swagger::OAuth2Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/omniauth/swagger/oauth2_definition.rb

Constant Summary collapse

OPTION_CLIENT_ID =
'client_id'.freeze
OPTION_CLIENT_SECRET =
'client_secret'.freeze
OPTION_AUTHORIZE_URL =
'authorize_url'.freeze
OPTION_TOKEN_URL =
'token_url'.freeze
OPTION_SCOPE =
'scope'.freeze
OPTION_SUBDOMAIN =
'subdomain'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(security_def, spec, options) ⇒ OAuth2Definition

Returns a new instance of OAuth2Definition.



15
16
17
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 15

def initialize(security_def, spec, options)
  @security_def, @spec, @options = security_def, spec, options
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



13
14
15
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 13

def client_id
  @client_id
end

#client_optionsObject (readonly)

Returns the value of attribute client_options.



13
14
15
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 13

def client_options
  @client_options
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



13
14
15
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 13

def client_secret
  @client_secret
end

Instance Method Details

#authorize_paramsObject



35
36
37
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 35

def authorize_params
  @security_def.extensions[:authorize_parameters]
end

#load_options(options) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 19

def load_options(options)
  options[:client_id] = @options[OPTION_CLIENT_ID]
  options[:client_secret] = @options[OPTION_CLIENT_SECRET]
  options[:client_options][OPTION_AUTHORIZE_URL] = prepare_url(@security_def.authorization_url)
  options[:client_options][OPTION_TOKEN_URL] = prepare_url(@security_def.token_url)
  options[:scope] = @options[OPTION_SCOPE]
end

#oauth2_keyObject



27
28
29
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 27

def oauth2_key
  @security_def.id.to_sym
end

#scopesObject



31
32
33
# File 'lib/omniauth/swagger/oauth2_definition.rb', line 31

def scopes
  @security_def.scopes ? @security_def.scopes.keys : []
end