mapper

package
v0.0.0-...-03c4a78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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.

func (*CELMapper) Map

func (m *CELMapper) Map(ctx context.Context, input *service.MapperInput) (claims.Claims, error)

Map evaluates the CEL expression and returns the resulting claims

func (*CELMapper) Script

func (m *CELMapper) Script() string

Script returns the CEL script used by this mapper

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL