Module: AtomicTenant::JwtToken

Included in:
CurrentApplicationInstanceMiddleware
Defined in:
lib/atomic_tenant/jwt_token.rb

Defined Under Namespace

Classes: InvalidTokenError

Constant Summary collapse

ALGORITHM =
'HS512'.freeze

Class Method Summary collapse

Class Method Details

.decode(token, algorithm = ALGORITHM, validate: true) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/atomic_tenant/jwt_token.rb', line 7

def self.decode(token, algorithm = ALGORITHM, validate: true)
  decoded_token = JWT.decode(
    token,
    AtomicTenant.jwt_secret,
    validate,
    { algorithm: algorithm }
  )
  return nil if AtomicTenant.jwt_aud != decoded_token[0]['aud']

  decoded_token
end