Class: AadAuth::Aad

Inherits:
Object
  • Object
show all
Defined in:
lib/aad_auth.rb

Instance Method Summary collapse

Instance Method Details

#auth!(token) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/aad_auth.rb', line 8

def auth!(token)
  keys = self.get_jwk_set()
  jwk_loader = ->(options) do
    @cached_keys = nil if options[:invalidate]
    @cached_keys ||= keys
  end

  claims = JWT.decode(token, nil, true, { algorithm: 'RS256', jwks: jwk_loader })
  self.validate_exp(claims[0]["exp"])
  self.validate_aud(claims[0]["aud"])
end