class OpenShift::AuthService

This class provides support to plugin different authentication providers. It should also be used as the Base class from which other Authentication plugins inherit.

Public Class Methods

instance() click to toggle source
# File lib/openshift/auth_service.rb, line 19
def self.instance
  @oo_auth_provider.new
end
provider=(provider_class) click to toggle source

Switch the Authentication plugin class.

@param provider_class [Class] Class that extends OpenShift::AuthService and provides an authentication plugin.

# File lib/openshift/auth_service.rb, line 15
def self.provider=(provider_class)
  @oo_auth_provider = provider_class
end

Public Instance Methods

authenticate(login, password) click to toggle source

Authenticate a user/password pair

@param login [String] - Login name of the user @param password [String] - Password of the user @return [Hash, false, nil] Returns one of:

* {
   :username => <An instance of CloudUser (retrieved via the model)>
  }
* {
   :username => <the unique identifier of this user>,
   :provider => (optional) <a scope under which this username is unique>
  }
* false or nil indicating authentication failure.
# File lib/openshift/auth_service.rb, line 37
def authenticate(login, password)
  {:username => login}
end
authenticate_request(controller) click to toggle source

The #authenticate_request method MAY be implemented. This method can be used if you need access to the Rails request to determine authentication, such as the ability to read a cookie.

NOTE: If you implement cookie support, you must ALSO enable CSRF protection in the console and the broker. By default the broker requires no forgery protection.

Implementors may write to the response to signal to a client that the request has failed, in which case authentication will be denied.

@param controller [BaseController] Controller against which the request is

being run. It can be used to retrieve the request and associated environment
Eg: controller.request.env["FOO"]

@return [Hash, false, nil] Returns one of:

* {
   :username => <An instance of CloudUser (retrieved via the model)>
  }
* {
   :username => <the unique identifier of this user>,
   :provider => (optional) <a scope under which this username is unique>
  }
* false or nil indicating authentication failure.
# File lib/openshift/auth_service.rb, line 65
def authenticate_request(controller)
end