Class: OAuth2::Authenticator
- Inherits:
- 
      Object
      
        - Object
- OAuth2::Authenticator
 
- Includes:
- FilteredAttributes
- Defined in:
- lib/oauth2/authenticator.rb
Instance Attribute Summary collapse
- 
  
    
      #id  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute id. 
- 
  
    
      #mode  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute mode. 
- 
  
    
      #secret  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute secret. 
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #apply(params)  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    Apply the request credentials used to authenticate to the Authorization Server. 
- 
  
    
      #initialize(id, secret, mode)  ⇒ Authenticator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Authenticator. 
Methods included from FilteredAttributes
Constructor Details
#initialize(id, secret, mode) ⇒ Authenticator
Returns a new instance of Authenticator.
| 12 13 14 15 16 | # File 'lib/oauth2/authenticator.rb', line 12 def initialize(id, secret, mode) @id = id @secret = secret @mode = mode end | 
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
| 9 10 11 | # File 'lib/oauth2/authenticator.rb', line 9 def id @id end | 
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
| 9 10 11 | # File 'lib/oauth2/authenticator.rb', line 9 def mode @mode end | 
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
| 9 10 11 | # File 'lib/oauth2/authenticator.rb', line 9 def secret @secret end | 
Class Method Details
.encode_basic_auth(user, password) ⇒ Object
| 42 43 44 | # File 'lib/oauth2/authenticator.rb', line 42 def self.encode_basic_auth(user, password) "Basic #{Base64.strict_encode64("#{user}:#{password}")}" end | 
Instance Method Details
#apply(params) ⇒ Hash
Apply the request credentials used to authenticate to the Authorization Server
Depending on the configuration, this might be as request params or as an
Authorization header.
User-provided params and header take precedence.
| 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # File 'lib/oauth2/authenticator.rb', line 27 def apply(params) case mode.to_sym when :basic_auth apply_basic_auth(params) when :request_body apply_params_auth(params) when :tls_client_auth apply_client_id(params) when :private_key_jwt params else raise NotImplementedError end end |