Documentation
¶
Overview ¶
Package auth provides JWT and API-key authentication for forge-generated Connect RPC services.
The library exposes a Validator that authenticates incoming Connect requests against a configured provider ("jwt", "api_key", "both", or "none") and a Connect interceptor that attaches the resulting Claims to the request context.
Generated forge projects import this package via a thin shim in pkg/middleware/auth_gen.go. The shim wires the project's Config from forge.yaml and exposes a project-local Claims alias (type Claims = auth.Claims).
Index ¶
- Constants
- Variables
- func JWKSKeyfunc(urls ...string) (jwt.Keyfunc, error)
- func JWKSKeyfuncWithSnapshot(url string, snap JWKSSnapshot) (jwt.Keyfunc, func(), error)
- type APIKeyConfig
- type Authenticator
- type Claims
- type ClerkOpts
- type Config
- type FirebaseOpts
- type HMACValidator
- type HMACValidatorConfig
- type InterceptorOptions
- type JWKSSnapshot
- type JWKSValidator
- type JWKSValidatorConfig
- type JWTConfig
- type KeyValidator
- type KeyValidatorFunc
- type MultiValidator
- type TokenValidator
- type UserResolver
- type Validator
- func (v *Validator) AuthenticateHeaders(ctx context.Context, headers http.Header, opts InterceptorOptions) (*Claims, error)
- func (v *Validator) Close() error
- func (v *Validator) ConnectInterceptor(opts InterceptorOptions, ...) connect.Interceptor
- func (v *Validator) Interceptor(opts InterceptorOptions, ...) connect.UnaryInterceptorFunc
- func (v *Validator) IsUnauthenticatedProcedure(procedure string, skipMethods []string) bool
- func (v *Validator) Provider() string
- func (v *Validator) SetKeyValidator(kv KeyValidator)
- func (v *Validator) Validate(token string) (*Claims, error)
Constants ¶
const ( ProviderNone = "none" ProviderJWT = "jwt" ProviderAPIKey = "api_key" ProviderBoth = "both" )
Provider names recognized by Config.
const DefaultJWKSSnapshotMaxAge = 7 * 24 * time.Hour
DefaultJWKSSnapshotMaxAge is how old a snapshot may be and still be trusted when JWKSSnapshot.MaxAge is unset.
const ( // RolesClaimAuto is the default for [JWTConfig.RolesClaim]: read the flat // `roles` array when the token has one, otherwise a Zitadel roles claim. RolesClaimAuto = "auto" )
Variables ¶
var ( // ErrAPIKeysDisabled: an API key was presented and no key validator is // installed. It is the scaffold's default until a project installs one. ErrAPIKeysDisabled = errors.New("API keys are not enabled on this server") // ErrMalformedAPIKey: the credential has the API-key prefix but is too // short to carry a lookup prefix, so no key validator is consulted. ErrMalformedAPIKey = errors.New("malformed API key") // ErrInvalidAPIKey: the key validator rejected the key, or failed. Its // own error is kept server-side (see [Authenticator.Authenticate]). ErrInvalidAPIKey = errors.New("invalid API key") // ErrBearerTokensDisabled: a non-key credential was presented to an // Authenticator built with no token validator (a key-only service). ErrBearerTokensDisabled = errors.New("bearer tokens are not accepted by this server; present an API key") )
Errors Authenticator.Authenticate fails with. Their text is what an unauthenticated caller reads, so none of it says more than the caller already knows.
Functions ¶
func JWKSKeyfunc ¶
JWKSKeyfunc builds an auto-refreshing jwt.Keyfunc backed by one or more JWKS endpoints. Signing keys are fetched once at construction (so a misconfigured or unreachable endpoint fails fast, at server boot) and then refreshed in the background for the life of the process.
The fail-fast half is what NoErrorReturnFirstHTTPReq buys: keyfunc's NewDefault DEFAULTS to swallowing the first fetch error and logging it, which turns a typo'd JWKS URL into an endless stream of per-request 401s nobody can attribute. A server that cannot reach its issuer's keys cannot authenticate anyone, so refusing to boot is both louder and no less available.
It is the seam Clerk and Firebase use internally; call it directly when wiring a custom JWKS issuer through NewJWKSValidator.
func JWKSKeyfuncWithSnapshot ¶ added in v0.1.46
func JWKSKeyfuncWithSnapshot(url string, snap JWKSSnapshot) (jwt.Keyfunc, func(), error)
JWKSKeyfuncWithSnapshot is JWKSKeyfunc for one URL with a JWKSSnapshot fallback, for callers composing their own validators (for example through Config.TokenValidators). The returned func stops the background retry and refresh; call it when the validator is retired. See the package JWKS snapshot notes for what is trusted and when.
Types ¶
type APIKeyConfig ¶
type APIKeyConfig struct {
// Header is the HTTP header name carrying the API key.
// Defaults to "X-API-Key" when empty.
Header string
}
APIKeyConfig holds API-key-specific settings.
func (APIKeyConfig) EffectiveHeader ¶
func (a APIKeyConfig) EffectiveHeader() string
EffectiveHeader returns Header or the "X-API-Key" default.
type Authenticator ¶ added in v0.1.46
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator checks the credential a request presents and returns its Claims. It accepts the two credentials a forge service takes, and the credential's SHAPE picks which validator checks it:
- an API key — a credential starting with apikey.KeyPrefix ("fk_"), the form apikey.Generate issues — goes to the KeyValidator installed with Authenticator.UseKeyValidator, with the request's context, because checking a key is a read of the application's own store;
- anything else goes to the token validator the Authenticator was built with — a JWT validator's Validate method.
The channel a credential arrived on never picks the validator. A key is checked as a key whether the caller sent "X-API-Key: fk_…" or "Authorization: Bearer fk_…" (many API clients can only send the latter), and no header can route a credential around the validator for its kind. The routing cannot be ambiguous: a JWT is three base64url segments, and base64url of a JSON header begins "eyJ", never "fk_".
Late binding ¶
A key validator reads the application's database, and the database is not open when the auth interceptor is built: a forge server builds its interceptor first, so that a server with no authenticator refuses to start before it touches any dependency. So the key validator is installed AFTER construction, once infrastructure is open, with UseKeyValidator; pass the Authenticate method value to the interceptor (the ValidateContext field of github.com/reliant-labs/forge/pkg/authn.Policy) and every later request sees whatever is installed. UseKeyValidator is safe to call while requests are being authenticated.
Failing closed ¶
Every path that cannot prove a principal is an error, never an anonymous pass, and no failure falls through to the other validator:
- an API key with no key validator installed: ErrAPIKeysDisabled;
- an API key too short to carry a lookup prefix: ErrMalformedAPIKey, before the key validator, and so the store behind it, is consulted;
- an API key the key validator rejects, or fails to check: ErrInvalidAPIKey;
- a non-key credential on an Authenticator with no token validator: ErrBearerTokensDisabled;
- a validator that returns neither claims nor an error.
A key validator's own error never reaches the caller: the text of a store error (a host, a DSN, a table name) is a diagnostic, not a message for an unauthenticated caller. The caller reads "invalid API key"; the error stays attached as the server-only cause (svcerr.Cause), which is what forge's logging interceptor writes beside the failure.
The zero value is not usable; construct with NewAuthenticator.
func NewAuthenticator ¶ added in v0.1.46
func NewAuthenticator(tokens func(token string) (*Claims, error)) *Authenticator
NewAuthenticator returns an Authenticator that checks bearer tokens with tokens — typically (*Validator).Validate from NewValidator, Clerk or Firebase — and rejects API keys until a key validator is installed.
tokens may be nil for a service that accepts API keys only: every non-key credential is then rejected with ErrBearerTokensDisabled.
func (*Authenticator) Authenticate ¶ added in v0.1.46
Authenticate checks credential — the raw value, with no "Bearer " scheme — and returns the claims of the principal it proves. ctx is the request's context; it reaches the key validator. See Authenticator for how a credential is routed and every way it fails.
func (*Authenticator) UseKeyValidator ¶ added in v0.1.46
func (a *Authenticator) UseKeyValidator(kv KeyValidator)
UseKeyValidator installs the validator API keys are checked with, replacing any installed before. nil uninstalls it: API keys are then rejected with ErrAPIKeysDisabled. Safe to call concurrently with Authenticator.Authenticate.
type Claims ¶
type Claims struct {
UserID string `json:"user_id"`
Email string `json:"email"`
OrgID string `json:"org_id"`
Role string `json:"role"`
Roles []string `json:"roles"`
Raw map[string]any `json:"raw,omitempty"`
}
Claims is the canonical claims shape produced by all forge auth flows.
The struct mirrors the per-project pkg/middleware/Claims that earlier forge versions generated. The generated shim re-exports it via type Claims = auth.Claims so existing project code (referring to middleware.Claims) keeps compiling.
Raw carries the full decoded JWT payload (or any provider-specific map a UserResolver chooses to attach). Projects that need access to claims outside the fixed fields — Supabase user_metadata, Auth0 app_metadata, Clerk org_permissions, etc. — should read from Raw instead of forking the Claims type.
type ClerkOpts ¶
type ClerkOpts struct {
// JWKSURL is the Clerk instance's JWKS endpoint, e.g.
// https://<your-subdomain>.clerk.accounts.dev/.well-known/jwks.json
// (typically read from CLERK_JWKS_URL). Required unless KeyFunc is set.
JWKSURL string
// Issuer, when set, is enforced (iss). Clerk's issuer is the instance's
// Frontend API URL, e.g. https://<your-subdomain>.clerk.accounts.dev.
// Strongly recommended in production so a token minted for a different
// Clerk instance is rejected.
Issuer string
// Audience, when set, is enforced (aud).
Audience string
// KeyFunc overrides JWKS fetching. Set it to inject a pre-built keyfunc
// (tests, or a custom JWKS client); when nil the validator builds one
// from JWKSURL via [JWKSKeyfunc].
KeyFunc jwt.Keyfunc
}
ClerkOpts configures a Clerk validator.
type Config ¶
type Config struct {
// Provider is one of "jwt", "api_key", "both", "none". Required.
Provider string
// JWT configures JWT validation. Used when Provider is "jwt" or "both".
JWT JWTConfig
// APIKey configures API key validation. Used when Provider is
// "api_key" or "both". A [KeyValidator] must be supplied separately
// via [Validator.SetKeyValidator] or [Config.KeyValidator].
APIKey APIKeyConfig
// SkipMethods is the list of fully-qualified Connect procedure names
// that bypass auth (in addition to the built-in gRPC health-check skip).
SkipMethods []string
// KeyValidator validates API keys. Required when APIKey auth is enabled.
KeyValidator KeyValidator
// TokenValidators, when non-empty, replaces the built-in single-secret
// JWT path with an ordered fallback chain. Each entry validates the
// bearer token independently; the first to accept wins. Use this when
// a service must accept tokens from more than one issuer — typically
// during an auth-provider migration (e.g. Supabase HMAC tokens
// alongside Auth0 JWKS tokens).
//
// When empty the legacy JWT (single secret / JWKSURL) path is used,
// preserving backwards compatibility for projects that only need one
// validator.
TokenValidators []TokenValidator
// UserResolver, when non-nil, projects the raw decoded JWT payload onto
// [Claims]. Use it when provider-specific claim shapes (Supabase
// user_metadata, Auth0 app_metadata, Clerk org_permissions, etc.) need
// to drive the Claims you hand to downstream code.
//
// When nil the validator uses built-in shape extraction (sub, email,
// org_id, role, roles) and still attaches the full payload to
// Claims.Raw so downstream code can inspect it.
UserResolver UserResolver
}
Config configures a Validator.
Provider selects the authentication scheme. JWT, APIKey and SkipMethods further customize each scheme. Every value is supplied by the caller — this package reads no environment variable of its own, so the key a validator trusts is always the key its constructor was handed.
type FirebaseOpts ¶
type FirebaseOpts struct {
// ProjectIDs is the set of accepted Firebase project IDs (typically read
// from FIREBASE_PROJECT_IDS, comma-separated). A token is accepted only
// when its aud is one of these AND its iss is
// securetoken.google.com/<that same project>. At least one is required.
// Accepting several lets one binary serve clients from multiple Firebase
// projects.
ProjectIDs []string
// KeyFunc overrides Google's JWKS endpoint (tests, or a custom key
// source). When nil the validator builds one from the well-known
// Firebase JWKS URL via [JWKSKeyfunc].
KeyFunc jwt.Keyfunc
}
FirebaseOpts configures a Firebase validator.
type HMACValidator ¶
type HMACValidator struct {
// contains filtered or unexported fields
}
HMACValidator validates JWTs signed with an HMAC algorithm (HS256/384/512).
Zero value is not usable; construct with NewHMACValidator. The secret is captured at construction; rotating it means constructing a new validator (which is cheap — no I/O).
func NewHMACValidator ¶
func NewHMACValidator(cfg HMACValidatorConfig) (*HMACValidator, error)
NewHMACValidator constructs a validator for HMAC-signed JWTs.
Returns an error when Secret is empty or SigningMethod is not an HS* algorithm.
func (*HMACValidator) ValidateToken ¶
func (v *HMACValidator) ValidateToken(tokenString string) (*Claims, error)
ValidateToken implements TokenValidator.
type HMACValidatorConfig ¶
type HMACValidatorConfig struct {
// SigningMethod is the expected JWT alg (e.g. "HS256"). Required.
SigningMethod string
// Secret is the symmetric secret. Required — this package reads no
// environment variable of its own, so the key a validator trusts is
// always the key its constructor was handed. Pass it from the app's
// typed config (declare the field `sensitive: true` and it arrives from
// the environment's secret provider, never as an inline manifest
// value); an app accepting several issuers passes each their own.
Secret string
// Issuer, when set, is enforced via jwt.WithIssuer.
Issuer string
// Audience, when set, is enforced via jwt.WithAudience.
Audience string
// Resolver, when non-nil, is given the raw JWT payload so projects can
// project provider-specific shapes onto [Claims] (and into Claims.Raw).
// Nil means use the built-in shape extraction.
Resolver UserResolver
// RolesClaim names the claim roles are read from; see [JWTConfig.RolesClaim].
RolesClaim string
}
HMACValidatorConfig configures an HMACValidator.
type InterceptorOptions ¶
type InterceptorOptions struct {
// SkipMethods overrides Config.SkipMethods when non-nil.
SkipMethods []string
}
InterceptorOptions configures Validator.Interceptor behaviour beyond the fields already on Config.
type JWKSSnapshot ¶ added in v0.1.46
type JWKSSnapshot struct {
// File is a path to a snapshot document. It is re-read when its content
// changes, so a re-delivery on key rotation needs no restart.
File string
// Inline is a snapshot document delivered as a config value (the
// secret-store path). It is parsed once, at construction.
Inline string
// MaxAge bounds how old a snapshot's delivered_at may be. Zero means
// [DefaultJWKSSnapshotMaxAge].
MaxAge time.Duration
// Issuer, when set, must equal the snapshot's issuer member (if the
// snapshot names one): a snapshot published for another issuer is
// refused, not merged. [NewValidator] fills it from JWTConfig.Issuer.
Issuer string
}
JWKSSnapshot configures the offline fallback key source of a JWKS-backed validator. The zero value means no snapshot, and the validator keeps its strict live-only behaviour.
type JWKSValidator ¶
type JWKSValidator struct {
// contains filtered or unexported fields
}
JWKSValidator validates JWTs whose signing key comes from a JWKS endpoint (or any other jwt.Keyfunc source — the pkg/auth library deliberately does not depend on a JWKS client implementation; the caller supplies one).
Construct via NewJWKSValidator with a pre-built jwt.Keyfunc (e.g. one returned by github.com/MicahParks/keyfunc/v3.NewDefaultCtx).
func NewJWKSValidator ¶
func NewJWKSValidator(cfg JWKSValidatorConfig) (*JWKSValidator, error)
NewJWKSValidator constructs a validator that delegates key resolution to cfg.KeyFunc (typically a JWKS-backed implementation).
func (*JWKSValidator) ValidateToken ¶
func (v *JWKSValidator) ValidateToken(tokenString string) (*Claims, error)
ValidateToken implements TokenValidator.
type JWKSValidatorConfig ¶
type JWKSValidatorConfig struct {
// SigningMethod is the expected JWT alg. Defaults to "RS256".
SigningMethod string
// KeyFunc resolves the signing key for the token. Required.
KeyFunc jwt.Keyfunc
// Issuer, when set, is enforced via jwt.WithIssuer.
Issuer string
// Audience, when set, is enforced via jwt.WithAudience.
Audience string
// Resolver, when non-nil, projects the raw JWT payload onto [Claims].
Resolver UserResolver
// RolesClaim names the claim roles are read from; see [JWTConfig.RolesClaim].
RolesClaim string
}
JWKSValidatorConfig configures a JWKSValidator.
type JWTConfig ¶
type JWTConfig struct {
// SigningMethod is the expected JWT alg value (e.g. "HS256", "RS256").
// Defaults to "RS256" when empty.
SigningMethod string
// Issuer, when set, is enforced via jwt.WithIssuer.
Issuer string
// Audience, when set, is enforced via jwt.WithAudience.
Audience string
// JWKSURL, when set, is the issuer's JWKS endpoint. [NewValidator]
// fetches it ONCE at construction (so an unreachable or malformed
// endpoint fails at server boot, not on the first request) and refreshes
// it in the background for the life of the process — the same
// [JWKSKeyfunc] machinery [Clerk] and [Firebase] use. This is the path
// every standard OIDC issuer (Auth0, Keycloak, Zitadel, Supabase, Okta)
// takes.
//
// Mutually exclusive with Secret: two key sources for one validator is a
// configuration error, and [NewValidator] rejects it rather than picking
// a winner. A service that must genuinely accept tokens from more than
// one issuer composes them explicitly via [Config.TokenValidators].
JWKSURL string
// JWKSDiscover, when set and JWKSURL is empty, yields the JWKS URL by
// asking the issuer (OIDC discovery). It runs on EVERY live attempt, so
// with a [JWKSSnapshot] an issuer that is down at boot — discovery
// included — still lets the validator start. Same exclusivity as JWKSURL.
JWKSDiscover func(ctx context.Context) (string, error)
// JWKSSnapshot is the optional offline fallback key source. With it,
// an issuer that is unreachable at boot no longer prevents startup when a
// fresh snapshot exists; see [JWKSSnapshot] for exactly what is trusted.
// Requires JWKSURL or JWKSDiscover.
JWKSSnapshot JWKSSnapshot
// Secret is the symmetric secret (HS*) or PEM-encoded public key
// (RS*/ES*). Mutually exclusive with JWKSURL.
Secret string
// KeyFunc, when non-nil, fully overrides key resolution. Useful for tests
// and for callers wiring custom JWKS clients.
KeyFunc jwt.Keyfunc
// RolesClaim names the claim [Claims.Roles] is read from. Empty or "auto"
// reads the flat `roles` array and, when the token has none, Zitadel's
// `urn:zitadel:iam:org:project:<audience>:roles` map (every project's, when
// Audience is unset). Set it to read exactly one claim: a flat array, a
// space or comma separated string, or a Zitadel-shaped role map.
RolesClaim string
}
JWTConfig holds JWT-specific settings.
func (JWTConfig) EffectiveSigningMethod ¶
EffectiveSigningMethod returns SigningMethod or the "RS256" default.
type KeyValidator ¶
KeyValidator validates an API key and returns the associated claims. Implementations typically look up the key in a database or cache.
type KeyValidatorFunc ¶ added in v0.1.46
KeyValidatorFunc adapts a function to a KeyValidator, the way http.HandlerFunc adapts one to an http.Handler — so a validator that closes over a database handle needs no named type.
func (KeyValidatorFunc) ValidateKey ¶ added in v0.1.46
ValidateKey calls f(ctx, key).
type MultiValidator ¶
type MultiValidator struct {
// contains filtered or unexported fields
}
MultiValidator tries each underlying validator in order and returns the first set of claims that parses cleanly.
When every validator rejects the token, MultiValidator returns the LAST validator's error (the chain typically ends with the strictest validator, so its error is the most informative). Use NewMultiValidator to construct.
func NewMultiValidator ¶
func NewMultiValidator(validators ...TokenValidator) (*MultiValidator, error)
NewMultiValidator constructs an ordered fallback chain. At least one underlying validator is required.
func (*MultiValidator) ValidateToken ¶
func (m *MultiValidator) ValidateToken(tokenString string) (*Claims, error)
ValidateToken implements TokenValidator by trying each underlying validator in order.
type TokenValidator ¶
type TokenValidator interface {
// ValidateToken parses tokenString and returns the parsed Claims. The
// returned error must be non-nil iff the token is invalid for THIS
// validator. MultiValidator uses error to decide whether to try the
// next validator in the chain.
ValidateToken(tokenString string) (*Claims, error)
}
TokenValidator validates a single bearer JWT and returns parsed Claims.
Implementations are expected to be safe for concurrent use. Each Validator represents one issuer/key configuration (e.g. one HMAC secret, one JWKS endpoint); compose multiple via MultiValidator when a service needs to accept tokens from more than one issuer (typical during an auth-provider migration — Supabase HMAC tokens alongside Auth0 JWKS tokens).
type UserResolver ¶
type UserResolver interface {
// Resolve receives the full decoded JWT payload (as a map, the
// shape jwt-go hands us) and must return a populated [Claims]. The
// raw payload should typically be copied onto Claims.Raw so
// downstream callers can still inspect provider-specific fields.
Resolve(rawClaims map[string]any) (*Claims, error)
}
UserResolver is an optional hook that translates a raw decoded JWT payload into Claims. Projects implement it when they need to consume provider-specific claim shapes (e.g. Supabase user_metadata, Auth0 app_metadata, Clerk org_role/org_permissions) without forking the Claims type.
The resolver is wired via Config.UserResolver; when nil the validator falls back to the built-in shape extraction (sub, email, org_id, role, roles) and still populates Claims.Raw with the full payload.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator authenticates Connect RPC requests against a configured provider. Construct with NewValidator; reuse a single Validator per service.
func Clerk ¶
Clerk returns a Validator for Clerk session tokens. Clerk issues RS256 JWTs whose signing keys come from a per-instance JWKS endpoint; the claim shape (sub / org_id / org_role / org_permissions) is mapped onto Claims by [clerkResolver].
// in SetupAuth(cfg *config.Config) — the values are typed config
// fields, declared in proto/<project>/config/v1/config.proto and pinned per
// environment, never read out of the process environment here.
validator, err := auth.Clerk(auth.ClerkOpts{
JWKSURL: cfg.JwtJwksUrl,
Issuer: cfg.JwtIssuer, // optional but recommended
})
return validator.Validate, nil
func Firebase ¶
func Firebase(opts FirebaseOpts) (*Validator, error)
Firebase returns a Validator for Firebase ID tokens. Firebase issues RS256 JWTs signed with Google's rotating keys; each accepted project pins its own iss+aud, so per-project enforcement is expressed as one JWKSValidator per project composed through a MultiValidator. Claims are mapped by [firebaseResolver] (sub = uid).
// A value this app's config does not carry yet gets a new field in
// proto/<project>/config/v1/config.proto — that is the one place a
// per-deployment value is declared.
validator, err := auth.Firebase(auth.FirebaseOpts{
ProjectIDs: strings.Split(cfg.FirebaseProjectIds, ","),
})
func NewValidator ¶
NewValidator returns a Validator wired for cfg.Provider.
It returns an error when Provider is unrecognized. The "none" provider is allowed and produces a Validator whose Interceptor is a no-op (useful for tests and for projects that haven't enabled auth yet).
func (*Validator) AuthenticateHeaders ¶
func (v *Validator) AuthenticateHeaders(ctx context.Context, headers http.Header, opts InterceptorOptions) (*Claims, error)
AuthenticateHeaders authenticates a request given its headers and returns the parsed claims (or an error). It is the testable core of Validator.Interceptor — the interceptor wraps this with the procedure-skip logic and context plumbing.
func (*Validator) Close ¶
Close stops the background JWKS refresh (and, with a snapshot, the live retry) a JWKS-backed Validator started.
func (*Validator) ConnectInterceptor ¶
func (v *Validator) ConnectInterceptor(opts InterceptorOptions, withClaims func(context.Context, *Claims) context.Context) connect.Interceptor
ConnectInterceptor returns a full connect.Interceptor (unary + streaming handler) that authenticates each request and stores the resulting claims on ctx via withClaims.
Use this in preference to Validator.Interceptor for any new wiring — connect-go silently bypasses connect.UnaryInterceptorFunc for streaming RPCs, which would otherwise leave streaming endpoints unauthenticated.
Streaming clients are pass-through: the auth interceptor is server-side.
func (*Validator) Interceptor ¶
func (v *Validator) Interceptor(opts InterceptorOptions, withClaims func(context.Context, *Claims) context.Context) connect.UnaryInterceptorFunc
Interceptor returns a unary-only Connect interceptor that authenticates each request and stores the resulting claims in the context using the supplied claims-context helper.
withClaims is the function the user's pkg/middleware exposes for putting claims into context (typically middleware.ContextWithClaims).
This entrypoint is kept for backwards compatibility with projects that wired auth as a connect.UnaryInterceptorFunc. New code should prefer Validator.ConnectInterceptor, which also covers streaming RPCs.
func (*Validator) IsUnauthenticatedProcedure ¶
IsUnauthenticatedProcedure reports whether procedure should bypass auth. This includes the built-in gRPC health-check skip plus any explicit skip list.
func (*Validator) SetKeyValidator ¶
func (v *Validator) SetKeyValidator(kv KeyValidator)
SetKeyValidator replaces the configured KeyValidator. Useful when the validator is constructed before the storage backend is ready.