Sha256: 45302eae798b4811cacf71105b01e95c5ee73a04a5c64e71b2532388ccbaee81
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require 'json/jwt' module OpenIDConnect class ResponseObject class IdToken < ConnectObject class InvalidToken < Exception; end attr_required :iss, :user_id, :aud, :exp, :iat attr_optional :acr, :auth_time, :nonce def initialize(attributes = {}) super (all_attributes - [:exp, :iat, :auth_time]).each do |key| self.send "#{key}=", self.send(key).try(:to_s) end end def verify!(expected = {}) exp.to_i >= Time.now.to_i && iss == expected[:issuer] && aud == expected[:client_id] && nonce == expected[:nonce] or raise InvalidToken.new('Invalid ID Token') end include JWTnizable class << self def decode(jwt_string, key_or_client) case key_or_client when Client OpenIDConnect::AccessToken.new( :client => key_or_client, :access_token => jwt_string ).id_token! else new JSON::JWT.decode(jwt_string, key_or_client) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openid_connect-0.2.1 | lib/openid_connect/response_object/id_token.rb |