Class: WardenOpenidAuth::Strategy

Inherits:
Warden::Strategies::Base
  • Object
show all
Defined in:
lib/warden_openid_auth/strategy.rb

Overview

This strategy uses OpenID to log the user in. This should be called as the callback phase of an OpenID auth code flow strategy. It will exchange the auth_code provided for an ID token and validate the ID Token.

Instance Method Summary collapse

Instance Method Details

#authenticate!Object

Authenticate and log the user in.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/warden_openid_auth/strategy.rb', line 23

def authenticate!
  if params.key?('error')
    fail!("There was a problem loging you in. #{params['error_description']}")
    return
  end

  case validate_user
  in Success(user)
    success!(user)
  in Failure(message:)
    fail!(message)
  end
end

#valid?Boolean

Only run strategy if this evaluates to true.

Returns:

  • (Boolean)


18
19
20
# File 'lib/warden_openid_auth/strategy.rb', line 18

def valid?
  params.key?('code') || params.key?('error')
end