Sha256: fea1246850d38145670db522f99604ac51a6b55642efd64aa5215d65943cac62

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Doorkeeper
  module OpenidConnect
    module Claims
      class Claim
        attr_accessor :name, :scope

        # http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
        # http://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims
        STANDARD_CLAIMS = {
          profile: %w[
            name family_name given_name middle_name nickname preferred_username
            profile picture website gender birthdate zoneinfo locale updated_at
          ],
          email: %w[ email email_verified ],
          address: %w[ address ],
          phone: %w[ phone_number phone_number_verified ],
        }

        def initialize(options = {})
          @name = options[:name]
          @scope = options[:scope]

          # use default scope for Standard Claims
          @scope ||= STANDARD_CLAIMS.find do |_scope, claims|
            claims.include? @name
          end.try(:first)

          # use profile scope as default fallback
          @scope ||= :profile
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doorkeeper-openid_connect-1.1.0 lib/doorkeeper/openid_connect/claims/claim.rb