class Restfulness::HttpAuthentication::Basic

Attributes

header[RW]

The Requests::AuthorizationHeader object generated in the request

Public Class Methods

new(header) click to toggle source
# File lib/restfulness/http_authentication/basic.rb, line 9
def initialize(header)
  self.header = header
end

Public Instance Methods

credentials() click to toggle source

Attempt to decode the credentials provided in the header.

# File lib/restfulness/http_authentication/basic.rb, line 19
def credentials
  @credentials ||= begin
    txt = ::Base64.decode64(header.params || '')
    txt.split(/:/, 2)
  end
end
password() click to toggle source
# File lib/restfulness/http_authentication/basic.rb, line 30
def password
  credentials[1]
end
username() click to toggle source
# File lib/restfulness/http_authentication/basic.rb, line 26
def username
  credentials[0]
end
valid?() click to toggle source

Determine if the header we were provided is valid.

# File lib/restfulness/http_authentication/basic.rb, line 14
def valid?
  header.schema == 'Basic' && credentials.length == 2
end