class Warden::JWTAuth::Middleware::RevocationManager

Revokes a token if it path and method match with configured

Constants

ENV_KEY

Debugging key added to `env`

Attributes

app[R]
config[R]
helper[R]

Public Class Methods

new(app) click to toggle source
# File lib/warden/jwt_auth/middleware/revocation_manager.rb, line 13
def initialize(app)
  @app = app
  @config = JWTAuth.config
  @helper = EnvHelper
end

Public Instance Methods

call(env) click to toggle source
# File lib/warden/jwt_auth/middleware/revocation_manager.rb, line 19
def call(env)
  env[ENV_KEY] = true
  response = app.call(env)
  revoke_token(env)
  response
end

Private Instance Methods

revoke_token(env) click to toggle source
# File lib/warden/jwt_auth/middleware/revocation_manager.rb, line 28
def revoke_token(env)
  token = HeaderParser.from_env(env)
  path_info = EnvHelper.path_info(env)
  method = EnvHelper.request_method(env)
  return unless token && token_should_be_revoked?(path_info, method)

  TokenRevoker.new.call(token)
end
token_should_be_revoked?(path_info, method) click to toggle source

:reek: ControlParameter

# File lib/warden/jwt_auth/middleware/revocation_manager.rb, line 38
def token_should_be_revoked?(path_info, method)
  revocation_requests = config.revocation_requests
  revocation_requests.each do |tuple|
    revocation_method, revocation_path = tuple
    return true if path_info.match(revocation_path) &&
                   method == revocation_method
  end
  false
end