Kern
Middleware guides

Middleware - BearerAuth

Detailed guide to Kern Bearer token authentication middleware with default and configurable validation paths.

Kern.BearerAuth and Kern.BearerAuthWithConfig

Use bearer auth middleware for simple token-protected APIs.

Signatures

func BearerAuth(token string) MiddlewareFunc
func BearerAuthWithConfig(config BearerAuthConfig) MiddlewareFunc

Basic example

app.Use(kern.BearerAuth("super-secret-token"))

Route-group example

api := app.Group("/api")
api.Use(kern.BearerAuth("super-secret-token"))

Notes

  • Prefer TLS for all token-protected routes.
  • For claim-based auth, use middleware.JWT from optional middleware package.