Class: Rack::OAuth2::Server::Options

Inherits:
Struct
  • Object
show all
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.

  • :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.

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

Instance Attribute Summary collapse

Instance Attribute Details

#access_token_pathObject

Returns the value of attribute access_token_path

Returns:

  • (Object)

    the current value of access_token_path



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def access_token_path
  @access_token_path
end

#authenticatorObject

Returns the value of attribute authenticator

Returns:

  • (Object)

    the current value of authenticator



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def authenticator
  @authenticator
end

#authorization_typesObject

Returns the value of attribute authorization_types

Returns:

  • (Object)

    the current value of authorization_types



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def authorization_types
  @authorization_types
end

#authorize_pathObject

Returns the value of attribute authorize_path

Returns:

  • (Object)

    the current value of authorize_path



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def authorize_path
  @authorize_path
end

#databaseObject

Returns the value of attribute database

Returns:

  • (Object)

    the current value of database



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def database
  @database
end

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def host
  @host
end

#loggerObject

Returns the value of attribute logger

Returns:

  • (Object)

    the current value of logger



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def logger
  @logger
end

#param_authenticationObject

Returns the value of attribute param_authentication

Returns:

  • (Object)

    the current value of param_authentication



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def param_authentication
  @param_authentication
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def path
  @path
end

#realmObject

Returns the value of attribute realm

Returns:

  • (Object)

    the current value of realm



152
153
154
# File 'lib/rack/oauth2/server.rb', line 152

def realm
  @realm
end