Sha256: b6a7586d35866a496f9c4c7bea7e225ab863b11faa64d0028e400746f7500467

Contents?: true

Size: 834 Bytes

Versions: 15

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

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

15 entries across 15 versions & 1 rubygems

Version Path
doorkeeper-openid_connect-1.8.10 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.8 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.7 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.6 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.5 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.4 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.3 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.2 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.1 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.0 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.8.0.pre.rc1 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.7.5 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.7.4 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.7.3 lib/doorkeeper/openid_connect/user_info.rb
doorkeeper-openid_connect-1.7.2 lib/doorkeeper/openid_connect/user_info.rb