Module: Ext::BasicAuth::Base
- Defined in:
- lib/ext/basic_auth.rb
Instance Method Summary collapse
-
#authenticate ⇒ Object
This method won’t be accessible if this module is on the roof of other all.
-
#basic_credentials ⇒ Object
Gets HTTP_Basic credendials from a request.
Instance Method Details
#authenticate ⇒ Object
This method won’t be accessible if this module is on the roof of other all.
40 41 42 43 44 |
# File 'lib/ext/basic_auth.rb', line 40 def authenticate creds = basic_credentials return super unless creds[0] return *creds end |
#basic_credentials ⇒ Object
Gets HTTP_Basic credendials from a request. It consists in an array of user and password.
30 31 32 33 34 35 36 |
# File 'lib/ext/basic_auth.rb', line 30 def basic_credentials if d = %w{X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION}.inject([]) \ { |d,h| env.has_key?(h) ? env[h].to_s.split : [] } return Base64.decode64(d[1]).split(':')[0..1] if d[0] == 'Basic' end [nil, nil] end |