Fix logout redirect through missing App Service Easy Auth endpoint - #1321
Fix logout redirect through missing App Service Easy Auth endpoint#1321Chad Palmer (chadpalmer) wants to merge 4 commits into
Conversation
|
Paul Lizer (@paullizer) Bionic711 Another quick update to fix 404 error when the App Service Easy Auth logout endpoint is not available in the development environment. |
Resolves the merge conflicts with Development (VERSION and release notes) and replaces the IS_DEVELOPMENT gate with a correct fix. Logout redirected to /.auth/logout and returned 404 whenever WEBSITE_AUTH_AAD_ALLOWED_TENANTS was set without Easy Auth actually running. That variable is configured by hand per the advanced environment variable guidance, so it was never evidence Easy Auth was intercepting requests. This affected production deployments, not just development ones. Detection now relies only on the X-MS-CLIENT-PRINCIPAL headers App Service injects into requests it intercepts, so Easy Auth logout is preserved wherever Easy Auth is genuinely active, including in development. Adds DISABLE_APP_SERVICE_EASY_AUTH_LOGOUT for deployments where Easy Auth is active but /.auth/* is not routed to the origin, plus debug logging of the logout path decision and a Logout Behavior Across Environments section in the local development guide. Also removes a customer hostname from the test fixture and replaces an exact VERSION assertion in the idle logout test with the shared version helper. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Chad Palmer (@chadpalmer), please review my update back, the goal is the same but the way we get there is a little different. Let me know if that works for you and your objectives. I appreciate taking the time to contribute! |
|
Resolved the merge conflicts with Why the approach changedThe 404 is real, but return any(easy_auth_headers) or bool(os.getenv('WEBSITE_AUTH_AAD_ALLOWED_TENANTS'))
Two further concerns with the original approach:
What it does nowDetection relies only on the
Worth noting: a localhost developer was never affected, since Keeping an escape hatch, but a purpose-named oneRow 4 above is the case auto-detection cannot resolve — Easy Auth is live, but a custom domain or gateway does not forward Also in this push
Version is Tests: |
Paul Lizer (@paullizer) Your updates look great. I was overly focused on our particular set up. Your improvements are more robust and account for other environments outside of dev. This looks good to go from my perspective. Thanks for taking the time to improve this PR. |
|
Paul Lizer (@paullizer) I went ahead and fixed the minor merge conflicts. Please let me know if you need anything else from me. Thanks and have a great weekend! |
Fixes #1324
Summary
/.auth/logouton App Service deployments that are not actually serving App Service Easy Auth. Detection now relies only on theX-MS-CLIENT-PRINCIPALheaders the platform injects into requests it intercepts, instead of trusting the manually configuredWEBSITE_AUTH_AAD_ALLOWED_TENANTSapplication setting.DISABLE_APP_SERVICE_EASY_AUTH_LOGOUTfor deployments where Easy Auth is enabled but/.auth/*is not routed through to the App Service origin, and trace the logout path decision through debug logging.example.env.v0.260.019.Scope note
This originally scoped the fix to development mode via
IS_DEVELOPMENT. The approach changed while resolving conflicts withDevelopment, because the underlying detection defect affected production deployments as well. See the discussion comment for the full reasoning.Local development was never affected by the original defect:
WEBSITE_HOSTNAMEis unset outside App Service, so the check returned early. The reported failure was a deployed non-production App Service.Validation
python -m py_compile application/single_app/config.py application/single_app/route_frontend_authentication.py functional_tests/test_app_service_easy_auth_logout.py functional_tests/test_idle_logout_timeout.pypython scripts/check_swagger_routes.py application/single_app/route_frontend_authentication.pypython functional_tests/test_app_service_easy_auth_logout.py— 5/5 passingpython functional_tests/test_idle_logout_timeout.py— 4/4 passingpython functional_tests/route_tests/test_route_blueprint_policy_inventory.py— 6/6 passingpython functional_tests/route_tests/test_route_unauthenticated_policy_contract.py— 4/4 passingpython functional_tests/route_tests/test_route_policy_test_coverage.py— 2/2 passingpython scripts/check_xss_sinks.py --base-sha origin/Development --head-sha HEAD application/single_app/config.py application/single_app/route_frontend_authentication.pypython scripts/check_broken_access_control.py --base-sha origin/Development --head-sha HEAD application/single_app/config.py application/single_app/route_frontend_authentication.pygit diff --check origin/Development...HEADNotes
origin/Development; merge conflicts inconfig.pyandrelease_notes.mdare resolved. Version moved to0.260.019becauseDevelopmenthad already published its ownv0.260.012.VERSION = "0.250.004"assertion intest_idle_logout_timeout.pywith the repository'sassert_app_version_at_leasthelper. That assertion was already failing onDevelopmentand breaks on every version bump.