common

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package common provides shared adapter utilities for goAuthly.

Concurrency: All exported types and functions are safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMetadataToResult

func ApplyMetadataToResult(result *authly.Result, meta map[string]string, attach bool)

ApplyMetadataToResult merges extracted metadata into the Result.Claims under the "_meta" namespace if enabled.

Types

type AdapterOptions

type AdapterOptions struct {
	RequiredMeta       RequiredMetadata
	AttachMetaToResult bool
}

AdapterOptions holds common adapter configuration.

type MetadataExtractor

type MetadataExtractor interface {
	// Get returns the value for the given key and whether it was found.
	Get(key string) (string, bool)
	// All returns all metadata key-value pairs.
	All() map[string]string
}

MetadataExtractor abstracts reading metadata from different transports.

type RequiredMetadata

type RequiredMetadata struct {
	// Keys lists required metadata/header names.
	// For HTTP headers, comparison is case-insensitive.
	// For gRPC metadata, keys are treated as lower-case per gRPC conventions.
	Keys []string

	// Enabled controls whether metadata validation is active.
	// If false, Validate always returns nil.
	Enabled bool
}

RequiredMetadata defines mandatory metadata keys that must be present in a request before authentication proceeds.

func (RequiredMetadata) ExtractMetadataMap

func (r RequiredMetadata) ExtractMetadataMap(ex MetadataExtractor) map[string]string

ExtractMetadataMap extracts the values of the required keys into a map. Only non-empty values are included. Keys are normalized to lower-case.

func (RequiredMetadata) Validate

func (r RequiredMetadata) Validate(ex MetadataExtractor) error

Validate checks that all required keys are present and non-empty. Returns ErrMissingRequiredMetadata wrapping the missing key name on failure.

Jump to

Keyboard shortcuts

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