mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Improve authenticator error handling
From PR Review https://github.com/safing/portbase/pull/59
This commit is contained in:
parent
eb0cbf58a8
commit
2fa29789de
2 changed files with 3 additions and 2 deletions
|
@ -38,7 +38,7 @@ type Authenticator func(ctx context.Context, s *http.Server, r *http.Request) (e
|
|||
// SetAuthenticator sets an authenticator function for the API endpoint. If none is set, all requests will be permitted.
|
||||
func SetAuthenticator(fn Authenticator) error {
|
||||
if module.Online() {
|
||||
return ErrAuthenticationAlreadySet
|
||||
return ErrAuthenticationImmutable
|
||||
}
|
||||
|
||||
authFnLock.Lock()
|
||||
|
|
|
@ -14,7 +14,8 @@ var (
|
|||
|
||||
// API Errors
|
||||
var (
|
||||
ErrAuthenticationAlreadySet = errors.New("the authentication function has already been set (or must be set earlier)")
|
||||
ErrAuthenticationAlreadySet = errors.New("the authentication function has already been set")
|
||||
ErrAuthenticationImmutable = errors.New("the authentication function can only be set before the api has started")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
Loading…
Add table
Reference in a new issue