stdcrpcauthfx

package
v0.0.217 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package stdcrpcauthfx provides ConnectRPC authentication and authorization via OIDC/JWKS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProtoExtensionScope

func ProtoExtensionScope(ext protoreflect.ExtensionType) fx.Option

ProtoExtensionScope returns an fx.Option that provides a ScopeResolver backed by the given protobuf method option extension type.

func Provide

func Provide() fx.Option

Provide returns an fx.Option that wires the stdauth module with config from the environment.

Types

type AccessControl

type AccessControl struct {
	// contains filtered or unexported fields
}

AccessControl holds all auth state: JWKS cache, config, and the authn middleware.

func (*AccessControl) Start

func (ac *AccessControl) Start(ctx context.Context) (err error)

Start initializes the JWKS cache and fetches the initial key set.

func (*AccessControl) Stop

func (ac *AccessControl) Stop(_ context.Context) error

Stop cancels the JWKS cache background refresh.

func (*AccessControl) Wrap

func (ac *AccessControl) Wrap(handler http.Handler) http.Handler

Wrap returns an HTTP handler that authenticates and authorizes requests.

type Claims

type Claims struct {
	Subject string
	Scopes  []string
}

Claims holds the authentication information extracted from a JWT.

func ClaimsFromContext

func ClaimsFromContext(ctx context.Context) Claims

ClaimsFromContext retrieves the claims stored by the auth middleware.

type Config

type Config struct {
	TokenIssuer   string `env:"TOKEN_ISSUER,required"`
	TokenAudience string `env:"TOKEN_AUDIENCE,required"`
}

Config holds the OIDC configuration read from environment variables.

type Params

type Params struct {
	fx.In
	fx.Lifecycle

	Logs          *zap.Logger
	Config        Config
	ScopeResolver ScopeResolver
	Clock         jwt.Clock `optional:"true"`
}

Params holds the dependencies for constructing AccessControl.

type Result

type Result struct {
	fx.Out

	AccessControl *AccessControl
}

Result holds the components produced by this module.

func New

func New(params Params) (Result, error)

New constructs a new AccessControl and registers its lifecycle hooks.

type ScopeResolver

type ScopeResolver interface {
	RequiredScope(procedure string) (string, error)
}

ScopeResolver resolves the required scope for a ConnectRPC procedure.

Directories

Path Synopsis
internal
v1

Jump to

Keyboard shortcuts

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