Documentation
¶
Index ¶
- func FetchPublicKeys(issuerURL string) (map[string]*rsa.PublicKey, error)
- func GetUserIDFromContext(r *http.Request) string
- func JWTAuth(validator *JWTValidator) func(http.Handler) http.Handler
- func Logging(l *slog.Logger, next http.Handler) http.Handler
- func NotifierValidator(next http.Handler) http.Handler
- func Prometheus(next http.Handler) http.Handler
- func SecurityHeaders(next http.Handler) http.Handler
- func SwitchValidator(v *validator.Validate) func(http.Handler) http.Handler
- type JWTValidator
- type ValidatedSwitch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchPublicKeys ¶
FetchPublicKeys fetches JWKS from the issuer's OIDC discovery endpoint
func GetUserIDFromContext ¶
GetUserIDFromContext retrieves the user ID from the request context
func JWTAuth ¶
func JWTAuth(validator *JWTValidator) func(http.Handler) http.Handler
JWTAuth is a middleware that validates JWT tokens from Authentik
func NotifierValidator ¶
NotifierValidator validates the Shoutrrr URL in the notifier field for POST requests
func Prometheus ¶
Prometheus wraps an http.Handler to provide prometheus metrics for the route.
func SecurityHeaders ¶
SecurityHeaders adds standard security headers to every response.
Types ¶
type JWTValidator ¶
type JWTValidator struct {
Audience string
Enabled bool
IssuerURL string
PublicKeys map[string]*rsa.PublicKey
}
JWTValidator holds configuration for JWT validation
type ValidatedSwitch ¶
type ValidatedSwitch struct {
Payload api.Switch
CheckInIntervalDuration time.Duration
ReminderThresholdDuration *time.Duration // Pointer since reminder is optional
}
ValidatedSwitch contains parsed payload/time fields to prevent parsing twice.
func FromContext ¶
func FromContext(ctx context.Context) (ValidatedSwitch, bool)
FromContext grabs a Switch payload from the context to ensure we only read the body once since we read the body to perform validation in this middleware.