Class: Simple::OAuth2::Configuration
- Inherits:
-
Object
- Object
- Simple::OAuth2::Configuration
- Includes:
- ClassAccessors, Constants
- Defined in:
- lib/simple_oauth2/configuration.rb
Overview
Simple::OAuth2 configuration class. Contains default or customized options that would be used in OAuth2 endpoints and helpers
Constant Summary
Constants included from Constants
Simple::OAuth2::Constants::DEFAULT_ACCESS_GRANT_CLASS, Simple::OAuth2::Constants::DEFAULT_ACCESS_TOKEN_CLASS, Simple::OAuth2::Constants::DEFAULT_CLIENT_CLASS, Simple::OAuth2::Constants::DEFAULT_CODE_LIFETIME, Simple::OAuth2::Constants::DEFAULT_ISSUE_REFRESH_TOKEN, Simple::OAuth2::Constants::DEFAULT_REALM, Simple::OAuth2::Constants::DEFAULT_RESOURCE_OWNER_CLASS, Simple::OAuth2::Constants::DEFAULT_TOKEN_LIFETIME, Simple::OAuth2::Constants::SUPPORTED_GRANT_TYPES, Simple::OAuth2::Constants::SUPPORTED_RESPONSE_TYPES
Instance Attribute Summary collapse
-
#access_grant_class_name ⇒ String
The names of the classes that represents OAuth2 roles.
-
#access_token_class_name ⇒ String
The names of the classes that represents OAuth2 roles.
-
#access_token_lifetime ⇒ Integer
Access Token and Authorization Code lifetime in seconds.
-
#allowed_grant_types ⇒ Array<String>
OAuth2 grant types (flows) allowed to be processed.
-
#allowed_response_types ⇒ Array<String>
OAuth2 response types (flows) allowed to be processed.
-
#authorization_code_lifetime ⇒ Integer
Access Token and Authorization Code lifetime in seconds.
-
#client_class_name ⇒ String
The names of the classes that represents OAuth2 roles.
-
#issue_refresh_token ⇒ Boolean
Specifies whether to generate a Refresh Token when creating an Access Token.
-
#on_refresh(&block) ⇒ Object
Accessor for on_refresh callback.
-
#realm ⇒ String
Realm value.
-
#resource_owner_authenticator(&block) ⇒ Object
Accessor for Resource Owner authenticator block.
-
#resource_owner_class_name ⇒ String
The names of the classes that represents OAuth2 roles.
-
#scopes_validator_class_name ⇒ String
Class name for the OAuth2 helper class that validates requested scopes against Access Token scopes.
-
#token_authenticator(&block) ⇒ Object
Accessor for Access Token authenticator block.
-
#token_generator_class_name ⇒ String
Class name for the OAuth2 helper class that generates unique token values.
Instance Method Summary collapse
-
#default_token_authenticator ⇒ Object
Default Access Token authenticator block.
-
#initialize ⇒ Configuration
constructor
Return a new instance of Configuration with default options.
-
#on_refresh_runnable? ⇒ Boolean
Indicates if on_refresh callback can be invoked.
Methods included from ClassAccessors
#access_grant_class, #access_token_class, #client_class, #resource_owner_class, #scopes_validator, #token_generator
Constructor Details
#initialize ⇒ Configuration
Return a new instance of Configuration with default options
69 70 71 |
# File 'lib/simple_oauth2/configuration.rb', line 69 def initialize setup! end |
Instance Attribute Details
#access_grant_class_name ⇒ String
The names of the classes that represents OAuth2 roles
13 14 15 |
# File 'lib/simple_oauth2/configuration.rb', line 13 def access_grant_class_name @access_grant_class_name end |
#access_token_class_name ⇒ String
The names of the classes that represents OAuth2 roles
13 14 15 |
# File 'lib/simple_oauth2/configuration.rb', line 13 def access_token_class_name @access_token_class_name end |
#access_token_lifetime ⇒ Integer
Access Token and Authorization Code lifetime in seconds
32 33 34 |
# File 'lib/simple_oauth2/configuration.rb', line 32 def access_token_lifetime @access_token_lifetime end |
#allowed_grant_types ⇒ Array<String>
OAuth2 grant types (flows) allowed to be processed
38 39 40 |
# File 'lib/simple_oauth2/configuration.rb', line 38 def allowed_grant_types @allowed_grant_types end |
#allowed_response_types ⇒ Array<String>
OAuth2 response types (flows) allowed to be processed
44 45 46 |
# File 'lib/simple_oauth2/configuration.rb', line 44 def allowed_response_types @allowed_response_types end |
#authorization_code_lifetime ⇒ Integer
Access Token and Authorization Code lifetime in seconds
32 33 34 |
# File 'lib/simple_oauth2/configuration.rb', line 32 def @authorization_code_lifetime end |
#client_class_name ⇒ String
The names of the classes that represents OAuth2 roles
13 14 15 |
# File 'lib/simple_oauth2/configuration.rb', line 13 def client_class_name @client_class_name end |
#issue_refresh_token ⇒ Boolean
Specifies whether to generate a Refresh Token when creating an Access Token
62 63 64 |
# File 'lib/simple_oauth2/configuration.rb', line 62 def issue_refresh_token @issue_refresh_token end |
#on_refresh(&block) ⇒ Object
Accessor for on_refresh callback. Set callback proc if called with block or returns current value of the accessor.
66 67 68 |
# File 'lib/simple_oauth2/configuration.rb', line 66 def on_refresh @on_refresh end |
#realm ⇒ String
Realm value
50 51 52 |
# File 'lib/simple_oauth2/configuration.rb', line 50 def realm @realm end |
#resource_owner_authenticator(&block) ⇒ Object
Accessor for Resource Owner authenticator block. Set it to proc if called with block or returns current value of the accessor.
56 57 58 |
# File 'lib/simple_oauth2/configuration.rb', line 56 def resource_owner_authenticator @resource_owner_authenticator end |
#resource_owner_class_name ⇒ String
The names of the classes that represents OAuth2 roles
13 14 15 |
# File 'lib/simple_oauth2/configuration.rb', line 13 def resource_owner_class_name @resource_owner_class_name end |
#scopes_validator_class_name ⇒ String
Class name for the OAuth2 helper class that validates requested scopes against Access Token scopes
26 27 28 |
# File 'lib/simple_oauth2/configuration.rb', line 26 def scopes_validator_class_name @scopes_validator_class_name end |
#token_authenticator(&block) ⇒ Object
Accessor for Access Token authenticator block. Set it to proc if called with block or returns current value of the accessor.
53 54 55 |
# File 'lib/simple_oauth2/configuration.rb', line 53 def token_authenticator @token_authenticator end |
#token_generator_class_name ⇒ String
Class name for the OAuth2 helper class that generates unique token values
20 21 22 |
# File 'lib/simple_oauth2/configuration.rb', line 20 def token_generator_class_name @token_generator_class_name end |
Instance Method Details
#default_token_authenticator ⇒ Object
Default Access Token authenticator block. Validates token value passed with the request params
114 115 116 117 118 |
# 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 |
#on_refresh_runnable? ⇒ Boolean
Indicates if on_refresh callback can be invoked.
98 99 100 |
# File 'lib/simple_oauth2/configuration.rb', line 98 def on_refresh_runnable? !on_refresh.nil? && on_refresh != :nothing end |