Module: Devise::JWT::RevocationStrategies::Whitelist

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise/jwt/revocation_strategies/whitelist.rb

Overview

This strategy must be included in the user model.

The JwtWhitelist table must include ‘jti`, `aud`, `exp` and `user_id` columns

In order to tell whether a token is revoked, it just tries to find the ‘jti` and `aud` values from the token on the `whitelisted_jwts` table for the respective user.

If the values don’t exist means the token was revoked. On revocation, it deletes the matching record from the ‘whitelisted_jwts` table.

On sign in, it creates a new record with the ‘jti` and `aud` values.

Instance Method Summary collapse

Instance Method Details

#on_jwt_dispatch(_token, payload) ⇒ Object

Warden::JWTAuth::Interfaces::User#on_jwt_dispatch :reek:FeatureEnvy



42
43
44
45
46
47
48
# File 'lib/devise/jwt/revocation_strategies/whitelist.rb', line 42

def on_jwt_dispatch(_token, payload)
  whitelisted_jwts.create!(
    jti: payload['jti'],
    aud: payload['aud'],
    exp: Time.at(payload['exp'].to_i)
  )
end