class Simple::OAuth2::Configuration
Simple::OAuth2
configuration class. Contains default or customized options that would be used in OAuth2
endpoints and helpers
Attributes
The names of the classes that represents OAuth2
roles
@return [String] class name
The names of the classes that represents OAuth2
roles
@return [String] class name
Access Token and Authorization Code lifetime in seconds
@return [Integer] lifetime in seconds
OAuth2
grant types (flows) allowed to be processed
@return [Array<String>] grant types
OAuth2
response types (flows) allowed to be processed
@return [Array<String>] response types
The names of the classes that represents OAuth2
roles
@return [String] class name
Specifies whether to generate a Refresh Token when creating an Access Token
@return [Boolean] true if need to generate refresh token
Callback that would be invoked during processing of Refresh Token request for the original Access Token found by token value
Realm value
@return [String] realm
Resource
Owner authenticator block option for customization
The names of the classes that represents OAuth2
roles
@return [String] class name
Class name for the OAuth2
helper class that validates requested scopes against Access Token scopes
@return [String] scope validator class name
Access Token authenticator block option for customization
Class name for the OAuth2
helper class that generates unique token values
@return [String] token generator class name
Public Class Methods
Return a new instance of Configuration
with default options
# File lib/simple_oauth2/configuration.rb, line 69 def initialize setup! end
Public Instance Methods
Default Access Token authenticator block. Validates token value passed with the request params
# File lib/simple_oauth2/configuration.rb, line 114 def default_token_authenticator lambda do |request| access_token_class.by_token(request.access_token) || request.invalid_token! end end
Indicates if on_refresh
callback can be invoked.
@return [Boolean]
true if callback can be invoked and false in other cases
# File lib/simple_oauth2/configuration.rb, line 98 def on_refresh_runnable? !on_refresh.nil? && on_refresh != :nothing end
Private Instance Methods
Default Resource
Owner authenticator block
# File lib/simple_oauth2/configuration.rb, line 139 def default_resource_owner_authenticator lambda do |_request| raise( 'Resource Owner find failed due to '\ 'Simple::OAuth2.configure.resource_owner_authenticator being unconfigured.' ) end end
Sets authenticators to gem defaults
# File lib/simple_oauth2/configuration.rb, line 155 def init_authenticators self.token_authenticator = default_token_authenticator self.resource_owner_authenticator = default_resource_owner_authenticator end
Sets OAuth2
helpers classes to gem defaults
# File lib/simple_oauth2/configuration.rb, line 149 def init_classes self.token_generator_class_name = Simple::OAuth2::UniqToken.name self.scopes_validator_class_name = Simple::OAuth2::Scopes.name end
Sets OAuth2
represents roles
# File lib/simple_oauth2/configuration.rb, line 161 def init_represents_roles self.access_token_class_name = DEFAULT_ACCESS_TOKEN_CLASS self.resource_owner_class_name = DEFAULT_RESOURCE_OWNER_CLASS self.client_class_name = DEFAULT_CLIENT_CLASS self.access_grant_class_name = DEFAULT_ACCESS_GRANT_CLASS end
Setup configuration to default options values
# File lib/simple_oauth2/configuration.rb, line 123 def setup! init_classes init_authenticators init_represents_roles self.access_token_lifetime = DEFAULT_TOKEN_LIFETIME self.authorization_code_lifetime = DEFAULT_CODE_LIFETIME self.allowed_grant_types = SUPPORTED_GRANT_TYPES self.allowed_response_types = SUPPORTED_RESPONSE_TYPES self.issue_refresh_token = DEFAULT_ISSUE_REFRESH_TOKEN self.on_refresh = :nothing self.realm = DEFAULT_REALM end