Sha256: bdaed1ef5961095294de2e212b47cc0995b343c211e058662ff1bd89db44862f

Contents?: true

Size: 648 Bytes

Versions: 6

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

module Warden
  module JWTAuth
    # Revokes a JWT using configured revocation strategy
    class TokenRevoker
      include JWTAuth::Import['revocation_strategies']

      # Revokes the JWT token
      #
      # @param token [String] a JWT
      def call(token)
        payload = TokenDecoder.new.call(token)
        scope = payload['scp'].to_sym
        user = PayloadUserHelper.find_user(payload)
        revocation_strategies[scope].revoke_jwt(payload, user)
      # rubocop:disable Lint/HandleExceptions
      rescue JWT::ExpiredSignature
      end
      # rubocop:enable Lint/HandleExceptions
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
warden-jwt_auth-0.5.0 lib/warden/jwt_auth/token_revoker.rb
warden-jwt_auth-0.4.2 lib/warden/jwt_auth/token_revoker.rb
warden-jwt_auth-0.4.1 lib/warden/jwt_auth/token_revoker.rb
warden-jwt_auth-0.4.0 lib/warden/jwt_auth/token_revoker.rb
warden-jwt_auth-0.3.6 lib/warden/jwt_auth/token_revoker.rb
warden-jwt_auth-0.3.5 lib/warden/jwt_auth/token_revoker.rb