Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CELMapper ¶
type CELMapper struct {
// contains filtered or unexported fields
}
CELMapper is a ClaimMapper that uses CEL (Common Expression Language) expressions to produce claims from the MapperInput.
The CEL expression has access to the following variables and functions:
- datasource(name) - function to fetch data from a named data source
- now_ms() - current Unix time in milliseconds
- fail(message) - reject the input with a structured error
- subject - the subject identity information as a map
- actor - the actor identity information as a map
- request - the request attributes as a map
The expression should evaluate to a map that will be used as the claims, or call fail() to abort mapping with a structured error.
Example CEL expressions:
// Simple claim from subject
{"user": subject.subject}
// Fetch from data source
{"roles": datasource("user_roles").roles}
// Reject unrecognised input
condition ? {"user": subject.subject} : fail("unsupported_token_type")
// Complex expressions
{
"user": subject.subject,
"ip": request.ip_address,
"roles": datasource("user_roles").roles,
"region": datasource("geo").region
}
func NewCELMapper ¶
func NewCELMapper(script string, opts ...CELMapperOption) (*CELMapper, error)
NewCELMapper creates a new CEL-based claim mapper. The script should be a CEL expression that evaluates to a map of claims.
type CELMapperOption ¶
type CELMapperOption func(*celMapperConfig)
CELMapperOption configures a CELMapper.
func WithClock ¶
func WithClock(clk clock.Clock) CELMapperOption
WithClock sets the clock used by the now_ms() CEL function. Defaults to the system clock.
Click to show internal directories.
Click to hide internal directories.