basicauth

package
v0.485.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

basicauth

A simple way to add basic auth to a http endpoint.

Examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuthSingleCredentials

func BasicAuthSingleCredentials(handlerFunction http.HandlerFunc, expectedUsername string, expectedPassword string) http.HandlerFunc

BasicAuthSingleCredentials wraps an http.HandlerFunc with HTTP Basic Authentication using a single set of hardcoded credentials.

If the request Authorization header is missing or the provided credentials do not match the expected `username` and `password`, the function responds with a 401 Unauthorized status and a "WWW-Authenticate: Basic" header.

Parameters:

  • handlerFunction: The function to be called after successful authentication.
  • expectedUsername: The expected username for authentication.
  • expectedPassword: The expected password for authentication.

Types

This section is empty.

Jump to

Keyboard shortcuts

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