Module: OpenIDConnect::JWTnizable

Included in:
RequestObject, ResponseObject::IdToken
Defined in:
lib/openid_connect/jwtnizable.rb

Instance Method Summary collapse

Instance Method Details

#as_jwt(key, algorithm = :RS256) {|token| ... } ⇒ Object

Yields:

  • (token)


7
8
9
10
11
12
# File 'lib/openid_connect/jwtnizable.rb', line 7

def as_jwt(key, algorithm = :RS256, &block)
  token = JSON::JWT.new as_json
  yield token if block_given?
  token = token.sign key, algorithm if algorithm != :none
  token
end

#to_jwt(key, algorithm = :RS256, &block) ⇒ Object



3
4
5
# File 'lib/openid_connect/jwtnizable.rb', line 3

def to_jwt(key, algorithm = :RS256, &block)
  as_jwt(key, algorithm, &block).to_s
end