Sha256: d326dd0c663e64550de9ed2640f39543b29344c0764dc7177b3b4c4538c86ec9

Contents?: true

Size: 803 Bytes

Versions: 12

Compression:

Stored size: 803 Bytes

Contents

module Doorkeeper
  module OpenidConnect
    class UserInfo
      include ActiveModel::Validations

      def initialize(access_token)
        @access_token = access_token
      end

      def claims
        {
          sub: subject
        }.merge ClaimsBuilder.generate(@access_token, :user_info)
      end

      def as_json(*_)
        claims.reject { |_, value| value.nil? || value == '' }
      end

      private

      def subject
        Doorkeeper::OpenidConnect.configuration.subject.call(resource_owner, application).to_s
      end

      def resource_owner
        @resource_owner ||= Doorkeeper::OpenidConnect.configuration.resource_owner_from_access_token.call(@access_token)
      end

      def application
        @application ||= @access_token.application
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
doorkeeper-openid_connect-1.7.1 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.7.0 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.6.3 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.6.2 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.6.1 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.6.0 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.5.5 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.5.4 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.5.3 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.5.2 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.5.1 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.5.0 lib/doorkeeper/openid_connect/user_info.rb