mirror of
https://github.com/h44z/wg-portal.git
synced 2026-11-20 20:53:40 +01:00
feat(auth): require changing default admin password (#778)
This commit is contained in:
@@ -18,6 +18,7 @@ const (
|
||||
|
||||
type UserAuthenticator interface {
|
||||
IsUserValid(ctx context.Context, id domain.UserIdentifier) bool
|
||||
IsDefaultPasswordInUse(ctx context.Context) bool
|
||||
}
|
||||
|
||||
type UserRepository interface {
|
||||
@@ -74,6 +75,12 @@ func (h AuthenticationHandler) LoggedIn(scopes ...Scope) func(next http.Handler)
|
||||
return
|
||||
}
|
||||
|
||||
if h.authenticator.IsDefaultPasswordInUse(r.Context()) {
|
||||
respond.JSON(w, http.StatusForbidden,
|
||||
model.Error{Code: http.StatusForbidden, Message: "default admin password must be changed first"})
|
||||
return
|
||||
}
|
||||
|
||||
if !UserHasScopes(user, scopes...) {
|
||||
// Abort the request with the appropriate error code
|
||||
respond.JSON(w, http.StatusForbidden,
|
||||
|
||||
Reference in New Issue
Block a user