oidcutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenericClaims added in v0.8.0

func GenericClaims[C any, T interface {
	*C
	ClaimsMapper
}](ctx context.Context, hasValidClaims func(claims map[string]any) bool, fallback func(ctx context.Context, custom map[string]any) map[string]any) map[string]any

GenericClaims returns the typed claims flattened via ClaimsMap on the typed path, or fallback(ctx, custom) on the generic-fallback path once custom has been confirmed valid by hasValidClaims. Returns an empty map when neither path yields claims.

func GenericExtract added in v0.8.0

func GenericExtract[C any, T interface {
	*C
	ClaimsMapper
}](ctx context.Context, hasValidClaims func(claims map[string]any) bool) (string, error)

GenericExtract returns the principal subject from ctx for provider C/T.

func GenericIsService added in v0.8.0

func GenericIsService[C any, T interface {
	*C
	ClaimsMapper
}](ctx context.Context, hasValidClaims func(claims map[string]any) bool) bool

GenericIsService reports whether ctx carries a valid token for provider C/T, on either the typed or generic-fallback path.

func GenericRoles added in v0.8.0

func GenericRoles(roleMapper mapper.Mapper, claims map[string]any) []string

GenericRoles maps claims via roleMapper, or returns nil when roleMapper is nil.

func HasAnyNonEmptyString

func HasAnyNonEmptyString(m map[string]any, keys ...string) bool

HasAnyNonEmptyString returns true if any of the provided keys in the map contain a non-empty string value.

func HasNonEmptyString

func HasNonEmptyString(m map[string]any, key string) bool

HasNonEmptyString returns true if the map contains a string value for the given key that is not empty.

Types

type ClaimsMapper added in v0.8.0

type ClaimsMapper interface {
	// ClaimsMap returns the typed claims as a flat map, seeded with any
	// canonical keys (e.g. "username") the provider wants alongside its raw
	// claim names. subject is the token's registered "sub" claim (may be
	// empty); implementations that don't derive "username" from it can
	// ignore the parameter.
	ClaimsMap(subject string) map[string]any
}

ClaimsMapper is implemented by provider-specific typed OIDC claims types (e.g. aws.Claims, flyio.Claims, githubactions.Claims) so the Generic* helpers below can flatten typed claims into the map[string]any shape ClaimRoleMapper rules and PrincipalSource.Claims callers expect.

Jump to

Keyboard shortcuts

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