Module: Rack::OAuth2::Server::IdTokenResponse

Included in:
Authorize::Extension::CodeAndIdToken::Response, Authorize::Extension::IdToken::Response
Defined in:
lib/rack/oauth2/server/id_token_response.rb

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rack/oauth2/server/id_token_response.rb', line 3

def self.included(klass)
  klass.send :attr_optional, :id_token, :private_key
  klass.class_eval do
    def jwt_string
      if id_token.is_a? OpenIDConnect::ResponseObject::IdToken
        raise AttrRequired::AttrMissing.new("'private_key' required.") unless private_key
        id_token.to_jwt private_key
      else
        id_token
      end
    end

    def protocol_params_with_id_token
      protocol_params_without_id_token.merge(
        :id_token => jwt_string
      )
    end
    alias_method_chain :protocol_params, :id_token
  end
end