fix(auth/csvauth): oops, should have added as auth.BasicAuthenticator, done

This commit is contained in:
AJ ONeal 2026-02-26 17:05:41 -07:00
parent ff8cdec1d7
commit 8ef2f73cb0
No known key found for this signature in database
4 changed files with 15 additions and 9 deletions

View File

@ -8,17 +8,14 @@ import (
"slices"
"strconv"
"strings"
"github.com/therootcompany/golib/auth"
)
type BasicAuthVerifier interface {
Verify(string, string) error
}
type Principle interface {
ID() string
Permissions() []string
}
const (
// deprecated, misspelling of PurposeDefault
DefaultPurpose = "login"
@ -233,4 +230,4 @@ func (c Credential) ToRecord() []string {
}
var _ BasicAuthVerifier = (*Credential)(nil)
var _ Principle = (*Credential)(nil)
var _ auth.BasicPrinciple = (*Credential)(nil)

View File

@ -23,6 +23,8 @@ import (
"sync"
"golang.org/x/crypto/bcrypt"
"github.com/therootcompany/golib/auth"
)
var ErrNotFound = errors.New("not found")
@ -368,7 +370,7 @@ func (a *Auth) gcmDecrypt(aes128key [16]byte, gcmNonce [12]byte, derived []byte)
// (because 'pass' is swapped with 'user' when 'pass' is empty)
// - the resulting 'user' must match BasicAuthTokenNames ("", "api", and "apikey" are the defaults)
// - then the token is (timing-safe) hashed to check if it exists, and then verified by its algorithm
func (a *Auth) Authenticate(name, secret string) (Principle, error) {
func (a *Auth) Authenticate(name, secret string) (auth.BasicPrinciple, error) {
if name == "" && secret == "" {
return nil, ErrUnauthorized
}
@ -463,3 +465,5 @@ func (a *Auth) cacheID(s string, n int) string {
name := base64.RawURLEncoding.EncodeToString(nameBytes)
return name
}
var _ auth.BasicAuthenticator = (*Auth)(nil)

View File

@ -1,5 +1,8 @@
module github.com/therootcompany/golib/auth/csvauth
go 1.24.3
go 1.25.0
require golang.org/x/crypto v0.42.0
require (
github.com/therootcompany/golib/auth v1.0.0
golang.org/x/crypto v0.42.0
)

View File

@ -1,2 +1,4 @@
github.com/therootcompany/golib/auth v1.0.0 h1:17hfwcJO/Efc22/8RcCTKUD49mhCc5tyoHiKonA3Slg=
github.com/therootcompany/golib/auth v1.0.0/go.mod h1:DSw8llmDkMtvMZWrzrTRtcaLPpPMsT6Sg+qwGf5O2U8=
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=