From c9737d1f9ffff68b82245b63a2af06f1123226de Mon Sep 17 00:00:00 2001 From: Gabriel20xx Date: Sun, 13 Sep 2026 12:30:19 +0200 Subject: [PATCH] mediaauth: expose SetAuthGuardBaseURL for live AuthGuard-URL retargeting A project built via NewWithStore previously had no way to react to ProjectConfigurator's live authguard_url push (coreconfig.Store.OnUpdate) the way a project holding its own *authclient.Client directly could via SetBaseURL - this closes that gap without exposing the client itself. Co-Authored-By: Claude Sonnet 5 --- backend/mediaauth/auth.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backend/mediaauth/auth.go b/backend/mediaauth/auth.go index 9ce5644..480b3b6 100644 --- a/backend/mediaauth/auth.go +++ b/backend/mediaauth/auth.go @@ -345,6 +345,22 @@ func (s *Service) enabled() bool { return s.authGuard != nil } +// SetAuthGuardBaseURL retargets the AuthGuard base URL this Service's +// internal authclient.Client calls, taking effect on its very next call - +// wire it as a coreconfig.Store's OnUpdate callback (see +// ProjectConfigurator/README.md's "Pushing core service info to other +// projects" section) so a live authguard_url change applies without a +// restart, the same as a project holding its own *authclient.Client +// directly. A no-op if this Service was constructed in auth-disabled mode +// (AUTHGUARD_URL unset at startup - see the "Auth-disabled mode" section): +// there is no client to retarget, and this package has no path to start +// authenticating requests it previously always let through. +func (s *Service) SetAuthGuardBaseURL(baseURL string) { + if s.authGuard != nil { + s.authGuard.SetBaseURL(baseURL) + } +} + func UserFromContext(ctx context.Context) *User { value, _ := ctx.Value(userContextKey).(*User) return value