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
Instance Method Details
#authorize_params ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/omniauth/strategies/gov.rb', line 60 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
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/omniauth/strategies/gov.rb', line 76 def build_access_token verifier = request.params["code"] redirect_uri = "#{.app_url}/#{.callback_path}".gsub!(%r{/+}, '/') atoken = client.auth_code.get_token( verifier, {"grant_type": "authorization_code", "code": verifier, "redirect_uri": redirect_uri, "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
55 56 57 58 |
# File 'lib/omniauth/strategies/gov.rb', line 55 def client ..merge!({connection_opts: {request: {params_encoder: GovBr::ParamsEncoder}}}) ::OAuth2::Client.new(.client_id, .client_secret, deep_symbolize(.)) end |
#prune!(hash) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/omniauth/strategies/gov.rb', line 48 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
44 45 46 |
# File 'lib/omniauth/strategies/gov.rb', line 44 def raw_info @raw_info ||= JWT.decode(credentials["id_token"], nil, false)[0] end |