diff --git a/internal/api/handlers/management/auth_files.go b/internal/api/handlers/management/auth_files.go index fd3bfdc3..351133d5 100644 --- a/internal/api/handlers/management/auth_files.go +++ b/internal/api/handlers/management/auth_files.go @@ -2585,6 +2585,7 @@ func PopulateAuthContext(ctx context.Context, c *gin.Context) context.Context { } return coreauth.WithRequestInfo(ctx, info) } + const kiroCallbackPort = 9876 func (h *Handler) RequestKiroToken(c *gin.Context) { @@ -2721,6 +2722,7 @@ func (h *Handler) RequestKiroToken(c *gin.Context) { } isWebUI := isWebUIRequest(c) + var forwarder *callbackForwarder if isWebUI { targetURL, errTarget := h.managementCallbackURL("/kiro/callback") if errTarget != nil { @@ -2728,7 +2730,8 @@ func (h *Handler) RequestKiroToken(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"error": "callback server unavailable"}) return } - if _, errStart := startCallbackForwarder(kiroCallbackPort, "kiro", targetURL); errStart != nil { + var errStart error + if forwarder, errStart = startCallbackForwarder(kiroCallbackPort, "kiro", targetURL); errStart != nil { log.WithError(errStart).Error("failed to start kiro callback forwarder") c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to start callback server"}) return @@ -2737,7 +2740,7 @@ func (h *Handler) RequestKiroToken(c *gin.Context) { go func() { if isWebUI { - defer stopCallbackForwarder(kiroCallbackPort) + defer stopCallbackForwarderInstance(kiroCallbackPort, forwarder) } socialClient := kiroauth.NewSocialAuthClient(h.cfg) @@ -2940,7 +2943,7 @@ func (h *Handler) RequestKiloToken(c *gin.Context) { Metadata: map[string]any{ "email": status.UserEmail, "organization_id": orgID, - "model": defaults.Model, + "model": defaults.Model, }, }