Documentation
¶
Overview ¶
Package basic provides Basic credential authenticators.
Index ¶
Examples ¶
Constants ¶
View Source
const MaxEntries = 256
MaxEntries bounds the work performed for one static Basic authentication.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Username string
Password string
Principal authentication.PrincipalSpec
}
Entry configures one accepted username and password pair.
type Static ¶
type Static struct {
// contains filtered or unexported fields
}
Static validates Basic credentials against a bounded immutable set. Only fixed-length keyed secret digests are retained and every entry is compared.
func NewStatic ¶
NewStatic validates and copies entries.
Example ¶
package main
import (
"context"
"fmt"
authentication "github.com/faustbrian/go-authentication"
"github.com/faustbrian/go-authentication/basic"
)
func main() {
authenticator, _ := basic.NewStatic([]basic.Entry{{
Username: "service", Password: "password",
Principal: authentication.PrincipalSpec{Subject: "service-account"},
}})
result, err := authenticator.Authenticate(
context.Background(),
authentication.NewBasicCredential("service", "password"),
)
principal, authenticated := result.Principal()
fmt.Println(err, authenticated, principal.Subject())
}
Output: <nil> true service-account
func (*Static) Authenticate ¶
func (s *Static) Authenticate(ctx context.Context, credential authentication.Credential) (authentication.Result, error)
Authenticate validates one Basic credential in constant work relative to the configured entry count.
Click to show internal directories.
Click to hide internal directories.