Class: Ape::Authent
Instance Method Summary collapse
- #add_to(req, authentication = nil) ⇒ Object
-
#initialize(username, password, scheme = nil) ⇒ Authent
constructor
A new instance of Authent.
- #load_plugin(authentication) ⇒ Object
Methods included from Util
Constructor Details
#initialize(username, password, scheme = nil) ⇒ Authent
Returns a new instance of Authent.
11 12 13 14 |
# File 'lib/ape/authent.rb', line 11 def initialize(username, password, scheme=nil) @username = username @password = password end |
Instance Method Details
#add_to(req, authentication = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ape/authent.rb', line 16 def add_to(req, authentication = nil) return unless @username && @password if (authentication) if authentication.strip.downcase.include? 'basic' req.basic_auth @username, @password else @auth_plugin ||= load_plugin(authentication) @auth_plugin.add_credentials(req, authentication, @username, @password) end else req.basic_auth @username, @password end end |
#load_plugin(authentication) ⇒ Object
30 31 32 33 |
# File 'lib/ape/authent.rb', line 30 def load_plugin(authentication) plugin = Authent.resolve_plugin(authentication, 'auth', 'credentials', true) plugin || (raise AuthenticationError, "Unknown authentication method: #{authentication}") end |