Kern
Middleware guides

Middleware - BasicAuth

Detailed guide to Kern BasicAuth middleware for HTTP Basic authentication on admin and internal endpoints.

Kern.BasicAuth and Kern.BasicAuthWithConfig

Use Basic auth middleware for low-complexity protected endpoints.

Signatures

func BasicAuth(username, password string) MiddlewareFunc
func BasicAuthWithConfig(config BasicAuthConfig) MiddlewareFunc

Example

admin := app.Group("/admin")
admin.Use(kern.BasicAuth("admin", "change-me"))

Notes

  • Use only behind HTTPS.
  • Best for internal/admin surfaces or temporary protection.