mirror of
https://github.com/therootcompany/golib.git
synced 2026-03-02 23:57:59 +00:00
fix(auth/csvauth): oops, should have added as auth.BasicAuthenticator, done
This commit is contained in:
parent
ff8cdec1d7
commit
8ef2f73cb0
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
@ -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=
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user