Class: Doorkeeper::OpenidConnect::Claims::Claim

Inherits:
Object
  • Object
show all
Defined in:
lib/doorkeeper/openid_connect/claims/claim.rb

Direct Known Subclasses

AggregatedClaim, DistributedClaim, NormalClaim

Constant Summary collapse

STANDARD_CLAIMS =
{
  profile: %i[
    name family_name given_name middle_name nickname preferred_username
    profile picture website gender birthdate zoneinfo locale updated_at
  ],
  email: %i[ email email_verified ],
  address: %i[ address ],
  phone: %i[ phone_number phone_number_verified ],
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Claim

Returns a new instance of Claim.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/doorkeeper/openid_connect/claims/claim.rb', line 19

def initialize(options = {})
  @name = options[:name].to_sym
  @response = Array.wrap(options[:response])
  @scope = options[:scope].to_sym if 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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/doorkeeper/openid_connect/claims/claim.rb', line 5

def name
  @name
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/doorkeeper/openid_connect/claims/claim.rb', line 5

def response
  @response
end

#scopeObject

Returns the value of attribute scope.



5
6
7
# File 'lib/doorkeeper/openid_connect/claims/claim.rb', line 5

def scope
  @scope
end