@@ -112,6 +112,19 @@ export default class SamlController {
112112 /**
113113 * 4. Generate AuthnRequest
114114 */
115+ const spEntityId = process . env . SSO_SP_ENTITY_ID || 'NOT_SET' ;
116+
117+ this . log (
118+ 'info' ,
119+ 'Generating SAML AuthnRequest:' ,
120+ '| Workspace:' ,
121+ sgr ( workspaceId , Effect . ForegroundCyan ) ,
122+ '| SP Entity ID:' ,
123+ sgr ( spEntityId , [ Effect . ForegroundMagenta , Effect . Bold ] ) ,
124+ '| ACS URL:' ,
125+ sgr ( acsUrl , Effect . ForegroundGray )
126+ ) ;
127+
115128 const { requestId, encodedRequest } = await this . samlService . generateAuthnRequest (
116129 workspaceId ,
117130 acsUrl ,
@@ -292,11 +305,14 @@ export default class SamlController {
292305 const tokens = await user . generateTokensPair ( workspace . sso ?. enforced || false ) ;
293306
294307 /**
295- * 6. Redirect to Garage with tokens
308+ * 6. Redirect to Garage SSO callback page with tokens
309+ * The SSO callback page will save tokens to store and redirect to finalReturnUrl
296310 */
297- const frontendUrl = new URL ( finalReturnUrl , process . env . GARAGE_URL || 'http://localhost:3000' ) ;
311+ const callbackPath = `/login/sso/${ workspaceId } ` ;
312+ const frontendUrl = new URL ( callbackPath , process . env . GARAGE_URL || 'http://localhost:3000' ) ;
298313 frontendUrl . searchParams . set ( 'access_token' , tokens . accessToken ) ;
299314 frontendUrl . searchParams . set ( 'refresh_token' , tokens . refreshToken ) ;
315+ frontendUrl . searchParams . set ( 'returnUrl' , finalReturnUrl ) ;
300316
301317 this . log (
302318 'success' ,
@@ -305,6 +321,8 @@ export default class SamlController {
305321 '| Workspace:' ,
306322 sgr ( workspaceId , Effect . ForegroundCyan ) ,
307323 '| Redirecting to:' ,
324+ sgr ( callbackPath , Effect . ForegroundGray ) ,
325+ '→' ,
308326 sgr ( finalReturnUrl , Effect . ForegroundGray )
309327 ) ;
310328
0 commit comments