Sha256: bd2b1fe275a642903ea1f6bc918d1279ac1a9a8f3954480b08815601576f54df

Contents?: true

Size: 1.27 KB

Versions: 11

Compression:

Stored size: 1.27 KB

Contents

module OpenIDConnect
  class RequestObject < ConnectObject
    attr_optional :client_id, :response_type, :redirect_uri, :scope, :state, :nonce, :display, :prompt, :user_info, :id_token
    validate :require_at_least_one_attributes

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

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

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

    def as_json_with_user_info(options = {})
      hash = as_json_without_user_info options
      if hash.include?(:user_info)
        hash[:userinfo] = hash.delete(:user_info)
      end
      hash.with_indifferent_access
    end
    alias_method_chain :as_json, :user_info

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

      def fetch(request_uri, key)
        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

11 entries across 11 versions & 1 rubygems

Version Path
openid_connect-0.3.5 lib/openid_connect/request_object.rb
openid_connect-0.3.4 lib/openid_connect/request_object.rb
openid_connect-0.3.3 lib/openid_connect/request_object.rb
openid_connect-0.3.2 lib/openid_connect/request_object.rb
openid_connect-0.3.1 lib/openid_connect/request_object.rb
openid_connect-0.3.0 lib/openid_connect/request_object.rb
openid_connect-0.2.4 lib/openid_connect/request_object.rb
openid_connect-0.2.3 lib/openid_connect/request_object.rb
openid_connect-0.2.2 lib/openid_connect/request_object.rb
openid_connect-0.2.1 lib/openid_connect/request_object.rb
openid_connect-0.2.0 lib/openid_connect/request_object.rb