Class: Omniauth::Strategies::Gov
- Inherits:
-
OmniAuth::Strategies::OAuth2
- Object
- OmniAuth::Strategies::OAuth2
- Omniauth::Strategies::Gov
- Defined in:
- lib/omniauth/strategies/gov.rb
Instance Method Summary collapse
-
#authorize_params ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
- #build_access_token ⇒ Object
- #client ⇒ Object
- #prune!(hash) ⇒ Object
- #raw_info ⇒ Object
- #request_phase ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/omniauth/strategies/gov.rb', line 59 def # rubocop:disable Metrics/AbcSize, Metrics/MethodLength .[:state] = SecureRandom.hex(24) .[:client_id] = [:client_id] .[:scope] = [:scope] .[:response_type] = 'code' .[:nonce] = SecureRandom.hex[0..11] params = . .merge(("authorize")) .merge() session["omniauth.pkce.verifier"] = .pkce_verifier if .pkce session["omniauth.state"] = params[:state] params end |
#build_access_token ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/omniauth/strategies/gov.rb', line 75 def build_access_token verifier = request.params["code"] atoken = client.auth_code.get_token( verifier, {"grant_type": "authorization_code", "code": verifier, "redirect_uri": OmniAuth.config.full_host+.callback_path, "code_verifier": session["omniauth.pkce.verifier"]}, {"Content-Type" => "application/x-www-form-urlencoded", "Authorization" => "Basic #{Base64.strict_encode64(.client_id+":"+.client_secret)}" }) atoken end |
#client ⇒ Object
39 40 41 42 |
# File 'lib/omniauth/strategies/gov.rb', line 39 def client ..merge!({connection_opts: {request: {params_encoder: GovBr::ParamsEncoder}}}) ::OAuth2::Client.new(.client_id, .client_secret, deep_symbolize(.)) end |
#prune!(hash) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/gov.rb', line 52 def prune!(hash) hash.delete_if do |_, value| prune!(value) if value.is_a?(Hash) value.nil? || (value.respond_to?(:empty?) && value.empty?) end end |
#raw_info ⇒ Object
48 49 50 |
# File 'lib/omniauth/strategies/gov.rb', line 48 def raw_info @raw_info ||= JWT.decode(credentials["id_token"], nil, false)[0] end |
#request_phase ⇒ Object
44 45 46 |
# File 'lib/omniauth/strategies/gov.rb', line 44 def request_phase redirect client.auth_code.({:redirect_uri => callback_url}.merge()) end |