Sha256: 46f45b3e454f8147791f7965d8a4ee6ae0e606ec77a20bba2fe20e6f487740a2

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module OpenIDConnect
  class RequestObject < ConnectObject
    include JWTnizable

    attr_optional :client_id, :response_type, :redirect_uri, :scope, :state, :nonce, :display, :prompt, :userinfo, :id_token
    alias_method :user_info, :userinfo
    validate :require_at_least_one_attributes

    def initialize(attributes = {})
      attributes[:userinfo] ||= attributes[:user_info]
      super attributes
    end

    def id_token=(attributes = {})
      @id_token = IdToken.new(attributes) if attributes.present?
    end

    def userinfo=(attributes = {})
      @userinfo = UserInfo.new(attributes) if attributes.present?
    end
    alias_method :user_info=, :userinfo=

    def as_json_with_mixed_keys(options = {})
      hash = as_json_without_mixed_keys options
      hash.with_indifferent_access
    end
    alias_method_chain :as_json, :mixed_keys

    class << self
      def decode(jwt_string, key = nil)
        new JSON::JWT.decode(jwt_string, key)
      end

      def fetch(request_uri, key = nil)
        jwt_string = OpenIDConnect.http_client.get_content(request_uri)
        decode jwt_string, key
      end
    end
  end
end

require 'openid_connect/request_object/claimable'
require 'openid_connect/request_object/id_token'
require 'openid_connect/request_object/user_info'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openid_connect-0.6.1 lib/openid_connect/request_object.rb
openid_connect-0.6.0 lib/openid_connect/request_object.rb