class OmniAuth::Strategies::DexEnergy

Constants

DEFAULT_SITE

Public Class Methods

logout_uri(client_id:, redirect_uri:, site: nil) click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 34
def logout_uri(client_id:, redirect_uri:, site: nil)
  site ||= DEFAULT_SITE

  encoded_redirect_uri = URI.encode_www_form_component(redirect_uri)

  "#{site}/oauth/logout?client_id=#{client_id}&redirect_uri=#{encoded_redirect_uri}"
end

Private Instance Methods

algorithms() click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 63
def algorithms
  oidc_well_known[:id_token_signing_alg_values_supported]
end
extract_raw_info(access_token) click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 85
def extract_raw_info(access_token)
  id_token = access_token.params.fetch('id_token')

  decoded = JWT.decode(id_token, nil, true,
                       algorithms: algorithms,
                       jwks: jwk_loader,
                       verify_aud: true,
                       verify_expiration: true,
                       verify_iat: true,
                       verify_iss: true,
                       verify_jti: true,
                       verify_not_before: true,
                       verify_sub: true)

  decoded.first
end
issuer_url() click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 49
def issuer_url
  options['client_options']['site']
end
jwk_loader() click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 74
def jwk_loader
  lambda do |options|
    if @cached_keys.nil? || options[:invalidate]
      # we need to load the keys
      @cached_keys = jwks
    end

    @cached_keys
  end
end
jwks() click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 67
def jwks
  jwks_uri = oidc_well_known[:jwks_uri]
  uri = URI.parse(jwks_uri)
  response = Net::HTTP.get(uri)
  JSON.parse(response, symbolize_names: true)
end
oidc_well_known() click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 53
def oidc_well_known
  if @well_known.nil?
    uri = URI.parse("#{issuer_url}/.well-known/openid-configuration")
    response = Net::HTTP.get(uri)
    @well_known = JSON.parse(response, symbolize_names: true)
  end

  @well_known
end
raw_info() click to toggle source
# File lib/omniauth/strategies/dex_energy.rb, line 45
def raw_info
  @raw_info ||= extract_raw_info(access_token)
end