Module: OAuth2

Defined in:
lib/oauth2/model.rb,
lib/oauth2/router.rb,
lib/oauth2/provider.rb,
lib/oauth2/model/client.rb,
lib/oauth2/model/schema.rb,
lib/oauth2/model/hashing.rb,
lib/oauth2/provider/error.rb,
lib/oauth2/provider/exchange.rb,
lib/oauth2/model/client_owner.rb,
lib/oauth2/model/authorization.rb,
lib/oauth2/model/resource_owner.rb,
lib/oauth2/provider/access_token.rb,
lib/oauth2/provider/authorization.rb

Defined Under Namespace

Modules: Model Classes: Provider, Router

Constant Summary collapse

ROOT =
File.expand_path(File.dirname(__FILE__) + '/..')
TOKEN_SIZE =
128
ACCESS_TOKEN =
'access_token'
ASSERTION =
'assertion'
ASSERTION_TYPE =
'assertion_type'
AUTHORIZATION_CODE =
'authorization_code'
CLIENT_ID =
'client_id'
CLIENT_SECRET =
'client_secret'
CODE =
'code'
CODE_AND_TOKEN =
'code_and_token'
DURATION =
'duration'
ERROR =
'error'
ERROR_DESCRIPTION =
'error_description'
EXPIRES_IN =
'expires_in'
GRANT_TYPE =
'grant_type'
OAUTH_TOKEN =
'oauth_token'
PASSWORD =
'password'
REDIRECT_URI =
'redirect_uri'
REFRESH_TOKEN =
'refresh_token'
RESPONSE_TYPE =
'response_type'
SCOPE =
'scope'
STATE =
'state'
TOKEN =
'token'
USERNAME =
'username'
INVALID_REQUEST =
'invalid_request'
UNSUPPORTED_RESPONSE =
'unsupported_response_type'
REDIRECT_MISMATCH =
'redirect_uri_mismatch'
UNSUPPORTED_GRANT_TYPE =
'unsupported_grant_type'
INVALID_GRANT =
'invalid_grant'
INVALID_CLIENT =
'invalid_client'
UNAUTHORIZED_CLIENT =
'unauthorized_client'
INVALID_SCOPE =
'invalid_scope'
INVALID_TOKEN =
'invalid_token'
EXPIRED_TOKEN =
'expired_token'
INSUFFICIENT_SCOPE =
'insufficient_scope'
ACCESS_DENIED =
'access_denied'

Class Method Summary collapse

Class Method Details

.generate_id(&predicate) ⇒ Object



18
19
20
21
22
# File 'lib/oauth2/provider.rb', line 18

def self.generate_id(&predicate)
  id = random_string
  id = random_string until predicate.call(id)
  id
end

.hashify(token) ⇒ Object



24
25
26
27
# File 'lib/oauth2/provider.rb', line 24

def self.hashify(token)
  return nil unless String === token
  Digest::SHA1.hexdigest(token)
end

.random_stringObject



14
15
16
# File 'lib/oauth2/provider.rb', line 14

def self.random_string
  rand(2 ** TOKEN_SIZE).to_s(36)
end