Class: BasicAuthCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/basic_auth_credentials.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(encoded_credentials) ⇒ BasicAuthCredentials

Returns a new instance of BasicAuthCredentials.



6
7
8
9
10
11
# File 'lib/basic_auth_credentials.rb', line 6

def initialize(encoded_credentials)
  encoded_credentials ||= ''
  encoded_credentials.sub!(/^Basic\s+/, '')
  decoded = Base64.decode64(encoded_credentials)
  @user_id, @password = decoded.split(':', 2)
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



4
5
6
# File 'lib/basic_auth_credentials.rb', line 4

def password
  @password
end

#user_idObject (readonly)

Returns the value of attribute user_id.



4
5
6
# File 'lib/basic_auth_credentials.rb', line 4

def user_id
  @user_id
end