mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-25 03:34:14 +00:00
try and fix bad oauth cache
This commit is contained in:
@@ -119,10 +119,11 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
|
||||
slog.Info("TEST_MODE enabled - will use HTTP for local DID resolution and transition:generic scope")
|
||||
}
|
||||
|
||||
// Create OAuth app (automatically configures confidential client for production)
|
||||
oauthApp, err := oauth.NewApp(baseURL, oauthStore, defaultHoldDID, cfg.Server.OAuthKeyPath, cfg.Server.ClientName)
|
||||
// Create OAuth client app (automatically configures confidential client for production)
|
||||
desiredScopes := oauth.GetDefaultScopes(defaultHoldDID)
|
||||
oauthClientApp, err := oauth.NewClientApp(baseURL, oauthStore, desiredScopes, cfg.Server.OAuthKeyPath, cfg.Server.ClientName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create OAuth app: %w", err)
|
||||
return fmt.Errorf("failed to create OAuth client app: %w", err)
|
||||
}
|
||||
if testMode {
|
||||
slog.Info("Using OAuth scopes with transition:generic (test mode)")
|
||||
@@ -132,7 +133,6 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// Invalidate sessions with mismatched scopes on startup
|
||||
// This ensures all users have the latest required scopes after deployment
|
||||
desiredScopes := oauth.GetDefaultScopes(defaultHoldDID)
|
||||
invalidatedCount, err := oauthStore.InvalidateSessionsWithMismatchedScopes(context.Background(), desiredScopes)
|
||||
if err != nil {
|
||||
slog.Warn("Failed to invalidate sessions with mismatched scopes", "error", err)
|
||||
@@ -141,7 +141,7 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Create oauth token refresher
|
||||
refresher := oauth.NewRefresher(oauthApp)
|
||||
refresher := oauth.NewRefresher(oauthClientApp)
|
||||
|
||||
// Wire up UI session store to refresher so it can invalidate UI sessions on OAuth failures
|
||||
if uiSessionStore != nil {
|
||||
@@ -189,7 +189,7 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
|
||||
Database: uiDatabase,
|
||||
ReadOnlyDB: uiReadOnlyDB,
|
||||
SessionStore: uiSessionStore,
|
||||
OAuthApp: oauthApp,
|
||||
OAuthClientApp: oauthClientApp,
|
||||
OAuthStore: oauthStore,
|
||||
Refresher: refresher,
|
||||
BaseURL: baseURL,
|
||||
@@ -202,7 +202,7 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Create OAuth server
|
||||
oauthServer := oauth.NewServer(oauthApp)
|
||||
oauthServer := oauth.NewServer(oauthClientApp)
|
||||
// Connect server to refresher for cache invalidation
|
||||
oauthServer.SetRefresher(refresher)
|
||||
// Connect UI session store for web login
|
||||
@@ -223,7 +223,7 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Resume OAuth session to get authenticated client
|
||||
session, err := oauthApp.ResumeSession(ctx, didParsed, sessionID)
|
||||
session, err := oauthClientApp.ResumeSession(ctx, didParsed, sessionID)
|
||||
if err != nil {
|
||||
slog.Warn("Failed to resume session", "component", "appview/callback", "did", did, "error", err)
|
||||
// Fallback: update user without avatar
|
||||
@@ -385,7 +385,7 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// OAuth client metadata endpoint
|
||||
mainRouter.Get("/client-metadata.json", func(w http.ResponseWriter, r *http.Request) {
|
||||
config := oauthApp.GetConfig()
|
||||
config := oauthClientApp.Config
|
||||
metadata := config.ClientMetadata()
|
||||
|
||||
// For confidential clients, ensure JWKS is included
|
||||
|
||||
Reference in New Issue
Block a user