ReckonJwt (reckon_jwt v0.2.1)
View SourceJWT authentication library for Reckon microservices.
Provides a simple, consistent API for JWT token operations across all Reckon services including token generation, validation, and refresh functionality.
Configuration
config :reckon_jwt, ReckonJwt.Guardian,
issuer: "reckon_identity",
secret_key: "your-secret-key",
ttl: {4, :hours}
Usage
# Generate session tokens
{:ok, tokens} = ReckonJwt.generate_session_tokens("account_123", "session_456")
# Validate tokens
{:ok, claims} = ReckonJwt.validate_token(token)
# Use in Phoenix pipelines
plug ReckonJwt.Middleware, required_scopes: ["read"]
Summary
Functions
Get configuration value with fallback.
Extract account ID from token (for debugging/logging).
Generate a simple access token without session context.
Generate session tokens (access + refresh) for authentication.
Refresh tokens using a valid refresh token.
Check if a token is expired.
Validate a session token specifically (requires session_id in claims).
Validate a JWT token and extract authentication information.
Functions
Get configuration value with fallback.
Extract account ID from token (for debugging/logging).
Generate a simple access token without session context.
Useful for service-to-service authentication.
Generate session tokens (access + refresh) for authentication.
Returns both access and refresh tokens with session information.
Examples
iex> {:ok, tokens} = ReckonJwt.generate_session_tokens("acc_123", "sess_456")
iex> tokens.account_id
"acc_123"
iex> tokens.session_id
"sess_456"
Refresh tokens using a valid refresh token.
Generates new access token while maintaining session context.
Check if a token is expired.
Validate a session token specifically (requires session_id in claims).
Validate a JWT token and extract authentication information.
Returns account and session information from the token.
Examples
iex> {:ok, tokens} = ReckonJwt.generate_session_tokens("acc_123", "sess_456")
iex> {:ok, result} = ReckonJwt.validate_token(tokens.access_token)
iex> result.account_id
"acc_123"