Class: Rack::OAuth2::Server::Options
- Inherits:
-
Struct
- Object
- Struct
- Rack::OAuth2::Server::Options
- Defined in:
- lib/rack/oauth2/server.rb
Overview
Options are:
-
:access_token_path – Path for requesting access token. By convention defaults to /oauth/access_token.
-
:authenticator – For username/password authorization. A block that receives the credentials and returns identity string (e.g. user ID) or nil.
-
:authorization_types – Array of supported authorization types. Defaults to [“code”, “token”], and you can change it to just one of these names.
-
:authorize_path – Path for requesting end-user authorization. By convention defaults to /oauth/authorize.
-
:database – Mongo::DB instance (this is a global option).
-
:expires_in – Number of seconds an auth token will live. If nil or zero, access token never expires.
-
:host – Only check requests sent to this host.
-
:path – Only check requests for resources under this path.
-
:param_authentication – If true, supports authentication using query/form parameters.
-
:realm – Authorization realm that will show up in 401 responses. Defaults to use the request host name.
-
:logger – The logger to use. Under Rails, defaults to use the Rails logger. Will use Rack::Logger if available.
-
:collection_prefix – Prefix to use for MongoDB collections created by rack-oauth2-server. Defaults to “oauth2”.
Authenticator is a block that receives either two or four parameters. The first two are username and password. The other two are the client identifier and scope. It authenticated, it returns an identity, otherwise it can return nil or false. For example:
oauth.authenticator = lambda do |username, password|
user = User.find_by_username(username)
user if user && user.authenticated?(password)
end
Assertion handler is a hash of blocks keyed by assertion_type. Blocks receive three parameters: the client, the assertion, and the scope. If authenticated, it returns an identity. Otherwise it can return nil or false. For example:
oauth.assertion_handler['facebook.com'] = lambda do |client, assertion, scope|
facebook = URI.parse('https://graph.facebook.com/me?access_token=' + assertion)
response = Net::HTTP.get_response(facebook)
user_data = JSON.parse(response.body)
user = User.from_facebook_data(user_data)
end
Assertion handlers are optional; if one is not present for a given assertion type, no error will result.
Instance Attribute Summary collapse
-
#access_token_path ⇒ Object
Returns the value of attribute access_token_path.
-
#assertion_handler ⇒ Object
Returns the value of attribute assertion_handler.
-
#authenticator ⇒ Object
Returns the value of attribute authenticator.
-
#authorization_types ⇒ Object
Returns the value of attribute authorization_types.
-
#authorize_path ⇒ Object
Returns the value of attribute authorize_path.
-
#collection_prefix ⇒ Object
Returns the value of attribute collection_prefix.
-
#database ⇒ Object
Returns the value of attribute database.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#param_authentication ⇒ Object
Returns the value of attribute param_authentication.
-
#path ⇒ Object
Returns the value of attribute path.
-
#realm ⇒ Object
Returns the value of attribute realm.
Instance Attribute Details
#access_token_path ⇒ Object
Returns the value of attribute access_token_path
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def access_token_path @access_token_path end |
#assertion_handler ⇒ Object
Returns the value of attribute assertion_handler
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def assertion_handler @assertion_handler end |
#authenticator ⇒ Object
Returns the value of attribute authenticator
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def authenticator @authenticator end |
#authorization_types ⇒ Object
Returns the value of attribute authorization_types
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def @authorization_types end |
#authorize_path ⇒ Object
Returns the value of attribute authorize_path
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def @authorize_path end |
#collection_prefix ⇒ Object
Returns the value of attribute collection_prefix
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def collection_prefix @collection_prefix end |
#database ⇒ Object
Returns the value of attribute database
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def database @database end |
#expires_in ⇒ Object
Returns the value of attribute expires_in
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def expires_in @expires_in end |
#host ⇒ Object
Returns the value of attribute host
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def logger @logger end |
#param_authentication ⇒ Object
Returns the value of attribute param_authentication
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def param_authentication @param_authentication end |
#path ⇒ Object
Returns the value of attribute path
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def path @path end |
#realm ⇒ Object
Returns the value of attribute realm
205 206 207 |
# File 'lib/rack/oauth2/server.rb', line 205 def realm @realm end |