middleware

package
v0.0.0-...-77c6198 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

FILE: pkg/middleware/webhook_auth.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HMACAuth

func HMACAuth[T hmac.Signable](
	getRepo func(T) string,
	ns credentials.KeyNamespace,
	persistence ports.Persistence,
	masterKey string,
) func(http.Handler) http.Handler

HMACAuth returns a middleware that:

  1. Reads and decodes the JSON body into T.
  2. Resolves the repository identified by getRepo(req).
  3. Validates the HMAC signature (timestamp check included).
  4. Injects the resolved *model.RepositoryMetadata into the request context.
  5. Restores r.Body so the next handler can decode it again.

func OIDCAuth

func OIDCAuth(allowedEmails, allowedAudiences, allowedAZPs []string) func(http.Handler) http.Handler

OIDCAuth agora é uma Factory Function que recebe a allowlist

func RepoFrom

func RepoFrom(ctx context.Context) *model.RepositoryMetadata

RepoFrom returns the *model.RepositoryMetadata injected by HMACAuth. Returns nil if the middleware was not applied (e.g. in LOCAL_DEV without auth).

func WebhookAuth

func WebhookAuth(authenticator auth.Authenticator) func(http.Handler) http.Handler

WebhookAuth cria middleware que valida usando o Authenticator fornecido

func WithLogger

func WithLogger(base zerolog.Logger) func(http.Handler) http.Handler

func WithRepo

WithRepo injects repo into ctx. Intended for use in tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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