class OmniAuth::Strategies::YahooOauth2

Constants

ALLOWED_ISSUERS
OPEN_ID_CONNECT_SCOPES

Public Instance Methods

raw_info() click to toggle source
# File lib/omniauth/strategies/yahoo_oauth2.rb, line 77
def raw_info
  @raw_info ||= access_token.get(userinfo_url).parsed
end

Private Instance Methods

authorize_params() click to toggle source

super saves SecureRandom state to session and merges authorize_options

This follows the example in omniauth-google-oauth2 and merges any request param with the same name as an authorize_option. It then saves state to the session (in case it was overwritten).

Probably the better way to handle this is to build it into “options_for” and have another option (e.g. authorize_request_params).

Calls superclass method
# File lib/omniauth/strategies/yahoo_oauth2.rb, line 117
def authorize_params
  super.tap do |params|
    options[:authorize_options].each do |k|
      unless [nil, ''].include?(request.params[k.to_s])
        params[k] = request.params[k.to_s]
      end
      session['omniauth.state'] = params[:state] if params[:state]
    end
  end
end
callback_url() click to toggle source

This follows the example in omniauth-google-oauth2.

Probably better to set the redirect_uri as a client option when creating the client, because OAuth2::Client knows how to handle it, but that requires updating OmniAuth::Strategies::OAuth2.

# File lib/omniauth/strategies/yahoo_oauth2.rb, line 88
def callback_url
  options[:redirect_uri] || (full_host + script_name + callback_path)
end
decode_info_token() click to toggle source

This is copied from the omniauth-google-oauth2 gem

# File lib/omniauth/strategies/yahoo_oauth2.rb, line 129
def decode_info_token
  unless options[:skip_jwt] || access_token['id_token'].nil?
    decoded = ::JWT.decode(access_token['id_token'], nil, false).first

    # We have to manually verify the claims because the third parameter to
    # JWT.decode is false since no verification key is provided.
    ::JWT::Verify.verify_claims(decoded,
                                verify_iss: true,
                                iss: ALLOWED_ISSUERS,
                                verify_aud: true,
                                aud: options.client_id,
                                verify_sub: false,
                                verify_expiration: true,
                                verify_not_before: true,
                                verify_iat: true,
                                verify_jti: false,
                                leeway: options[:jwt_leeway])

    decoded
  end
end
prune!(hash) click to toggle source

This is copied from the omniauth-google-oauth2 gem

# File lib/omniauth/strategies/yahoo_oauth2.rb, line 102
def prune!(hash)
  hash.delete_if do |_, v|
    prune!(v) if v.is_a?(Hash)
    v.nil? || (v.respond_to?(:empty?) && v.empty?)
  end
end
userinfo_url() click to toggle source
# File lib/omniauth/strategies/yahoo_oauth2.rb, line 92
def userinfo_url
  options.client_options.site + options.userinfo_url
end
verified_email() click to toggle source

This is copied from the omniauth-google-oauth2 gem

# File lib/omniauth/strategies/yahoo_oauth2.rb, line 97
def verified_email
  raw_info['email_verified'] ? raw_info['email'] : nil
end