class Grape::OAuth2::Configuration
Grape::OAuth2
configuration class. Contains default or customized options that would be used in OAuth2
endpoints and helpers.
Constants
- APIMissing
Grape::OAuth2
configuration error for missing API required forOAuth2
classes.- DEFAULT_CODE_LIFETIME
Default Authorization Code TTL ()in seconds)
- DEFAULT_REALM
Default realm value
- DEFAULT_TOKEN_LIFETIME
Default Access Token TTL (in seconds)
- Error
Default
Grape::OAuth2
configuration error class.- SUPPORTED_GRANT_TYPES
Currently supported (by the gem)
OAuth2
grant types
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
OAuth2 grant types (flows) allowed to be processed
@return [Array<String>] grant 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, false in other case
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
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] scopes 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
# File lib/grape_oauth2/configuration.rb, line 73 def initialize reset! end
Public Instance Methods
Default Access Token authenticator block. Validates token value passed with the request params.
# File lib/grape_oauth2/configuration.rb, line 79 def default_token_authenticator lambda do |request| access_token_class.authenticate(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/grape_oauth2/configuration.rb, line 110 def on_refresh_runnable? !on_refresh.nil? && on_refresh != :nothing end
Reset configuration to default options values.
# File lib/grape_oauth2/configuration.rb, line 115 def reset! initialize_classes initialize_authenticators self.access_token_lifetime = DEFAULT_TOKEN_LIFETIME self.authorization_code_lifetime = DEFAULT_CODE_LIFETIME self.allowed_grant_types = %w[password client_credentials] self.issue_refresh_token = false self.on_refresh = :nothing self.realm = DEFAULT_REALM end
Private Instance Methods
Sets authenticators to gem defaults.
# File lib/grape_oauth2/configuration.rb, line 138 def initialize_authenticators self.token_authenticator = default_token_authenticator end
Sets OAuth2
helpers classes to gem defaults.
# File lib/grape_oauth2/configuration.rb, line 132 def initialize_classes self.scopes_validator_class_name = Grape::OAuth2::Scopes.name self.token_generator_class_name = Grape::OAuth2::UniqueToken.name end