Token Sanitizer Module.
This module provides functionality for sanitizing sensitive tokens such as access tokens and credentials by masking their signatures or sensitive parts without masking the non-sensitive but useful parts. It supports various token formats including Nebius IAM tokens and JWT tokens.
The module defines token versions with their prefixes, delimiters, and signature positions, allowing for flexible sanitization based on token type.
| Class | |
Default implementation of TokenVersionExtractor using predefined versions. |
| Class | |
Main class for sanitizing tokens based on extracted version information. |
| Class | |
Represents a token version with its structural properties. |
| Class | |
Abstract base class for extracting token version from a token string. |
| Function | sanitize |
Sanitize tokens without signatures by limiting visible payload length. |
| Function | sanitize |
Sanitize unrecognized tokens by masking after a certain length. |
| Constant | ACCESS |
Predefined token formats for access tokens. |
| Constant | CREDENTIALS |
Predefined token formats for all types of credentials. |
| Constant | MASK |
The mask printed instead of sensitive parts of tokens. |
| Constant | MAX |
Maximum length of visible payload before masking. |
| Constant | NO |
Constant indicating no signature position in the token. |
Sanitize tokens without signatures by limiting visible payload length.
For tokens without a signature, this function shows the full token if it's short enough, otherwise masks the excess with MASK_STRING.
| Parameters | |
token:str | The full token string. |
prefix:str | The prefix of the token version. |
| Returns | |
str | The sanitized token. |
Predefined token formats for access tokens.
This dictionary maps version names to TokenVersion objects for supported access token formats.
| Value |
|
Predefined token formats for all types of credentials.
This dictionary includes all access token versions plus additional credential formats like DE1 and JWT.
| Value |
|