-
Notifications
You must be signed in to change notification settings - Fork 136
Description
Are you accessing the CLI from the default port :4280 ?
- No, I am using a different port number (
--port) and accessing the CLI from that port - Yes, I am accessing the CLI from port
:4280
Describe the bug
According to documentation, the staticwebapp.config.json supports a .referrer redirect for the auth routes. The .referrer should be replaced by the route the user was attempting to access before the auth redirect.
However, the SWA emulator (and auth emulator page?) treat the redirect path as a plain string. It is not substituted by the expected path.
To Reproduce
- Create a static web app. Restrict access using
routesinstaticwebapp.config.json. Users must be authenticated to access any page.{ "route": "/*", "allowedRoles": ["authenticated"] }
- Provide an auth redirect for any unauthorized response using
responseOverridesinstaticwebapp.config.json."responseOverrides":{"401":{"statusCode":302,"redirect":"/.auth/login/aad?post_login_redirect_uri=.referrer"}}
- User loads
GET http://localhost:4280/my-application-path?data=x - User is not authenticated and does not meet required
allowedRoles. - User is redirected to auth emulator page at
http://localhost:4280/.auth/login/aad?post_login_redirect_uri=.referrer$^{10}$ - User clicks "Login" in the emulator.
- Page is stuck in infinite loading loop. Page does not leave login emulator. SWA is attempting to use the
.referreras a valid application path, instead of replacing it with the actual path.$^{11}$
Expected behavior
10. Emulator should redirect user to authenticate at route http://localhost:4280/.auth/login/aad?post_login_redirect_uri=my-application-path%3Fdata%3Dx instead.
11. After clicking "Login" the emulator redirects the user to GET http://localhost:4280/my-application-path?data=x.
Relevant Logs:
[swa] ------------------- processing route -------------------
[swa] --------------------------------------------------------
[swa] processing /.auth/login/.referrer
...
[swa] - matchingRouteRule:
[swa] - route: /*
[swa] - allowedRoles:
[swa] - 0: authenticated
[swa] checking auth request
[swa] - auth request detected
[swa] processing auth request
[swa] - auth returned 404
[swa] checking response overrides for status code 404
[swa] - no rules found.
[swa] GET http://localhost:4280/404.html - 404
[swa] GET http://localhost:4280/404.html - 404
Desktop (please complete the following information):
- OS: Windows
- Version 11