Class: Jsapi::Controller::Authentication::Credentials::HTTP::Basic

Inherits:
Base
  • Object
show all
Defined in:
lib/jsapi/controller/authentication/credentials/http/basic.rb

Overview

Holds a username and password passed according to HTTP Basic Authentication.

Instance Attribute Summary collapse

Attributes inherited from Base

#auth_param, #auth_scheme

Instance Method Summary collapse

Constructor Details

#initialize(authorization) ⇒ Basic

Returns a new instance of Basic.



19
20
21
22
23
24
# File 'lib/jsapi/controller/authentication/credentials/http/basic.rb', line 19

def initialize(authorization)
  super
  @username, @password =
    Base64.decode64(auth_param).split(':', 2) \
    if auth_scheme == 'Basic' && auth_param.present?
end

Instance Attribute Details

#passwordObject (readonly)

The decoded password.



14
15
16
# File 'lib/jsapi/controller/authentication/credentials/http/basic.rb', line 14

def password
  @password
end

#usernameObject (readonly)

The decoded username.



17
18
19
# File 'lib/jsapi/controller/authentication/credentials/http/basic.rb', line 17

def username
  @username
end

Instance Method Details

#well_formed?Boolean

:nodoc:

Returns:

  • (Boolean)


26
27
28
# File 'lib/jsapi/controller/authentication/credentials/http/basic.rb', line 26

def well_formed? # :nodoc:
  !username.nil? && !password.nil?
end