Class: DeviseOam::Devise::Strategies::HeaderAuthenticatable

Inherits:
Devise::Strategies::Base
  • Object
show all
Defined in:
lib/devise_oam/strategies/header_authenticatable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authenticatableObject (readonly)

Returns the value of attribute authenticatable.



5
6
7
# File 'lib/devise_oam/strategies/header_authenticatable.rb', line 5

def authenticatable
  @authenticatable
end

Instance Method Details

#authenticate!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/devise_oam/strategies/header_authenticatable.rb', line 12

def authenticate!         
  oam_data = request.headers[DeviseOam.oam_header]
  ldap_data = request.headers[DeviseOam.ldap_header] if DeviseOam.ldap_header
  attributes = get_attributes

  if oam_data.blank?
    fail!("OAM authentication failed")
  else
    @authenticatable = AuthenticatableEntity.new(oam_data, ldap_data, attributes)
    user = find_or_create_user
    success!(user)
  end
end

#set_roles?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/devise_oam/strategies/header_authenticatable.rb', line 26

def set_roles?
  !DeviseOam.ldap_header.blank? && authenticatable.ldap_roles
end

#valid?Boolean

strategy is only valid if there is a DeviseOam.oam_header header in the request

Returns:

  • (Boolean)


8
9
10
# File 'lib/devise_oam/strategies/header_authenticatable.rb', line 8

def valid?
  request.headers[DeviseOam.oam_header]
end