Module: Philiprehberger::JwtKit::Revocation

Defined in:
lib/philiprehberger/jwt_kit/revocation.rb

Overview

Token revocation support with an in-memory store.

Defined Under Namespace

Classes: MemoryStore

Class Method Summary collapse

Class Method Details

.extract_jti(token) ⇒ String?

Extracts the JTI claim from a JWT token without verifying its signature.

Parameters:

  • token (String)

    JWT token

Returns:

  • (String, nil)

    the JTI, or nil if the token is malformed



11
12
13
14
15
16
17
18
19
# File 'lib/philiprehberger/jwt_kit/revocation.rb', line 11

def self.extract_jti(token)
  parts = token.split('.')
  return nil unless parts.length == 3

  payload = JSON.parse(Base64.urlsafe_decode64(parts[1]))
  payload['jti']
rescue JSON::ParserError, ArgumentError
  nil
end