Auth: Separate anonymous settings to its own struct (#97791)

separate anonymous settings to its own struct
This commit is contained in:
Jo
2024-12-13 10:46:27 +01:00
committed by GitHub
parent fc7805957e
commit 40d3b02648
18 changed files with 75 additions and 53 deletions
+5 -5
View File
@@ -45,7 +45,7 @@ func ProvideAnonymousDeviceService(usageStats usagestats.Service, authBroker aut
a := &AnonDeviceService{
log: log.New("anonymous-session-service"),
localCache: localcache.New(29*time.Minute, 15*time.Minute),
anonStore: anonstore.ProvideAnonDBStore(sqlStore, cfg.AnonymousDeviceLimit),
anonStore: anonstore.ProvideAnonDBStore(sqlStore, cfg.Anonymous.DeviceLimit),
serverLock: serverLockService,
cfg: cfg,
limitValidator: validator,
@@ -60,7 +60,7 @@ func ProvideAnonymousDeviceService(usageStats usagestats.Service, authBroker aut
anonDeviceService: a,
}
if cfg.AnonymousEnabled {
if cfg.Anonymous.Enabled {
authBroker.RegisterClient(anonClient)
authBroker.RegisterPostLoginHook(a.untagDevice, 100)
}
@@ -171,7 +171,7 @@ func (a *AnonDeviceService) TagDevice(ctx context.Context, httpReq *http.Request
// ListDevices returns all devices that have been updated between the given times.
func (a *AnonDeviceService) ListDevices(ctx context.Context, from *time.Time, to *time.Time) ([]*anonstore.Device, error) {
if !a.cfg.AnonymousEnabled {
if !a.cfg.Anonymous.Enabled {
a.log.Debug("Anonymous access is disabled, returning empty result")
return []*anonstore.Device{}, nil
}
@@ -181,7 +181,7 @@ func (a *AnonDeviceService) ListDevices(ctx context.Context, from *time.Time, to
// CountDevices returns the number of devices that have been updated between the given times.
func (a *AnonDeviceService) CountDevices(ctx context.Context, from time.Time, to time.Time) (int64, error) {
if !a.cfg.AnonymousEnabled {
if !a.cfg.Anonymous.Enabled {
a.log.Debug("Anonymous access is disabled, returning empty result")
return 0, nil
}
@@ -190,7 +190,7 @@ func (a *AnonDeviceService) CountDevices(ctx context.Context, from time.Time, to
}
func (a *AnonDeviceService) SearchDevices(ctx context.Context, query *anonstore.SearchDeviceQuery) (*anonstore.SearchDeviceQueryResult, error) {
if !a.cfg.AnonymousEnabled {
if !a.cfg.Anonymous.Enabled {
a.log.Debug("Anonymous access is disabled, returning empty result")
return nil, nil
}