Pull request 2456: 7985-fix-contol-profile

Updates #7985.

Squashed commit of the following:

commit 1d5a3e66cc046ac8be6c0ebe7f5e06bc3e2a5e72
Merge: bdc76b1b1 52398e27e
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Aug 28 19:05:51 2025 +0300

    Merge branch 'master' into 7985-fix-contol-profile

commit bdc76b1b10
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Aug 26 15:47:07 2025 +0300

    home: imp code

commit aef012ed02
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Aug 26 13:14:39 2025 +0300

    home: add tests

commit 799e8b49a1
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Aug 25 16:59:06 2025 +0300

    all: fix control profile
This commit is contained in:
Stanislav Chzhen
2025-08-28 19:17:24 +03:00
parent 52398e27ec
commit 146b6dd094
8 changed files with 167 additions and 20 deletions

View File

@@ -54,7 +54,7 @@ type authConfig struct {
// rateLimiter manages the rate limiting for login attempts. It must not be
// nil.
rateLimiter loginRaateLimiter
rateLimiter loginRateLimiter
// trustedProxies is a set of subnets considered as trusted.
trustedProxies netutil.SubnetSet
@@ -75,12 +75,27 @@ type authConfig struct {
// auth stores web user information and handles authentication.
type auth struct {
logger *slog.Logger
rateLimiter loginRaateLimiter
// logger is used to log the operation of the auth module.
logger *slog.Logger
// rateLimiter manages rate limiting for login attempts.
rateLimiter loginRateLimiter
// trustedProxies is a set of subnets considered trusted.
trustedProxies netutil.SubnetSet
sessions aghuser.SessionStorage
users aghuser.DB
isGLiNet bool
// sessions stores web users' sessions.
sessions aghuser.SessionStorage
// users stores user credentials.
users aghuser.DB
// isGLiNet indicates whether GLiNet mode is enabled.
isGLiNet bool
// isUserless indicates that there are no users defined in the configuration
// file.
isUserless bool
}
// newAuth returns the new properly initialized *auth.
@@ -111,6 +126,7 @@ func newAuth(ctx context.Context, conf *authConfig) (a *auth, err error) {
sessions: s,
users: userDB,
isGLiNet: conf.isGLiNet,
isUserless: len(conf.users) == 0,
}, nil
}
@@ -174,6 +190,8 @@ func (a *auth) addUser(ctx context.Context, u *webUser, password string) (err er
panic(err)
}
a.isUserless = false
a.logger.DebugContext(ctx, "added user", "login", u.Name)
return nil