Skip to content

Commit 472db43

Browse files
lorr1claude
andcommitted
Document validation re-check and storage injection limits
Address review nits on the auth-server constructors. NewEmbeddedAuthServer validates cfg before createStorage and NewEmbeddedAuthServerWithStorage validates again for direct callers. Note the re-check at the first call site so the duplication does not read as an accident. Document what the injected storage does not solve on NewEmbeddedAuthServerWithStorage: a shared backend lets replicas share persisted state but provides no cross-replica delivery or session affinity, which stay the caller responsibility. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Laurel Orr <laurel@stacklok.com>
1 parent 92314d9 commit 472db43

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎pkg/authserver/runner/embeddedauthserver.go‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ func NewEmbeddedAuthServer(ctx context.Context, cfg *authserver.RunConfig) (*Emb
7676
// Fail loudly on operator-supplied misconfiguration (e.g. a baseline
7777
// scope absent from scopes_supported) BEFORE touching storage or any
7878
// other side-effecting work, so a bad config never reaches the network
79-
// or filesystem.
79+
// or filesystem. NewEmbeddedAuthServerWithStorage re-validates for callers
80+
// that invoke it directly; this earlier check keeps the failure ahead of
81+
// createStorage on this path.
8082
if err := cfg.Validate(); err != nil {
8183
return nil, fmt.Errorf("invalid run config: %w", err)
8284
}
@@ -101,6 +103,16 @@ func NewEmbeddedAuthServer(ctx context.Context, cfg *authserver.RunConfig) (*Emb
101103
// lets external composition (e.g. an enterprise build) inject a decorated
102104
// storage.Storage aggregate.
103105
//
106+
// What the injection does NOT solve: the supplied storage is the sole
107+
// persistence boundary for this server instance. Injecting a shared backend
108+
// (e.g. Redis) lets replicas share persisted state — DCR registrations,
109+
// pending authorizations, upstream tokens — but it does not provide
110+
// cross-replica message delivery or fan-out, and it does not establish session
111+
// affinity. A request must still reach a replica that can resolve its session
112+
// from the shared store; pinning a session to a replica (or ensuring all
113+
// session state is in the shared store) remains the caller's responsibility,
114+
// typically at the load balancer.
115+
//
104116
// The supplied storage MUST also implement storage.DCRCredentialStore (both
105117
// OSS MemoryStorage and RedisStorage do); the constructor returns an error if
106118
// it does not. It also validates cfg, so direct callers get the same

0 commit comments

Comments
 (0)