Class: OmniAuth::Strategies::Valid
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Valid
- Defined in:
- lib/omniauth/strategies/valid.rb
Overview
extracted and adapted from https://github.com/gencat/omniauth-idcat_mobil/blob/master/lib/omniauth/strategies/idcat_mobil.rb VALID references:
Instance Method Summary collapse
- #callback_url ⇒ Object
- #client ⇒ Object
-
#extra ⇒ Object
extra: this method returns information not directly related with the user.
-
#raw_info ⇒ Object
The
callback_phaseis the second phase, after the user returns from the authentication provider site.
Instance Method Details
#callback_url ⇒ Object
119 120 121 |
# File 'lib/omniauth/strategies/valid.rb', line 119 def callback_url full_host + callback_path end |
#client ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/omniauth/strategies/valid.rb', line 56 def client .[:site] = .site base_url = .site base_url = URI.join(base_url, "/#{request[:locale]}/") if .with_locale_path_segment .[:authorize_url] = URI.join(base_url, "/o/oauth2/auth").to_s .[:token_url] = URI.join(base_url, "/o/oauth2/token").to_s .[:authorize_params] = { scope: :autenticacio_usuari, response_type: :code, approval_prompt: :auto, access_type: :online } # options.client_options[:auth_token_params] = { # client_id: super.id, # client_secret: super.secret, # redirect_uri: callback_url # } super end |
#extra ⇒ Object
extra: this method returns information not directly related with the user
47 48 49 50 51 52 53 54 |
# File 'lib/omniauth/strategies/valid.rb', line 47 def extra { identifier_type: raw_info["identifierType"], method: raw_info["method"], assurance_level: raw_info["assuranceLevel"], status: raw_info["status"] } end |
#raw_info ⇒ Object
The callback_phase is the second phase, after the user returns from the authentication provider site.
The result of the authentication may have ended in error, or success.
In case of success we still have to ask the authentication provider for the access_token.
That's what we do in this callback.
def callback_phase
custom_log("In callback_phase with request params: #OmniAuth::Strategies::Valid.requestrequest.params")
custom_log("Both should be equal otherwise a 'CSRF detected' error is raised: params state =? [#OmniAuth::Strategies::Valid.session["omniauthsession["omniauth.state"]] session state.")
super
end
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/omniauth/strategies/valid.rb', line 103 def raw_info if @raw_info custom_log("Access token response was: #{access_token.try(:response)}") else custom_log("Performing getUserInfo...") response = access_token.get(.user_info_path) result = [:status, :headers, :body].collect { |m| response.send(m) } custom_log("getUserInfo response status/headers/body: #{result}") @raw_info = response.parsed # Logout to avoid problems with Valid's cookie session when trying to login again. logout_url = URI.join(.site, "/o/oauth2/logout?token=#{access_token.token}").to_s access_token.get(logout_url) end @raw_info end |