Skip to main content

Module utils

Module utils 

Source
Expand description

Shared helpers: path matching, Redis key/value plumbing, signing-method resolution and the package’s custom duration format.

Functions§

build_redis_key
Creates a Redis key with the configured prefix.
deserialize_session_data
Deserializes JSON data from Redis into session data.
format_user
Renders a user for the callback page and JSON responses: id and roles plus any extra fields the application attached in User::user.
go_duration_string
Renders a duration the way Go’s time.Duration.String does, e.g. 5m0s or 8760h0m0s. The tokenlife claim uses this format, so tokens stay readable by the Go implementation of this package.
is_excluded_path
Reports whether path starts with any prefix in excluded. Prefix matching is intentional so callers can opt entire route trees out of authentication (e.g. /api/public).
parse_custom_duration
Parses values such as 30s, 15m, 1h, 7d, 4w, 1mo or 1y. The empty string falls back to default_input.
resolve_signing_method
Maps a configured signing-method name onto a JWT algorithm, defaulting to HS256 for empty or unrecognised values.
serialize_session_data
Serializes session data to JSON for Redis storage.
string_claim
Safely extracts a string value from a decoded claim set.
validate_session_data
Validates session data for required fields.