Skip to content

Conversation

pamelafox
Copy link
Collaborator

@pamelafox pamelafox commented Dec 2, 2024

Purpose

I discovered that logout for ACA built-in auth was still resulting in a CORS error, and it seemed to be due to an empty string domain in the CORS list. This PR changes the bicep variables so that we remove duplicate and empty domains for the domains that are passed to ACA/AppService. Previously, we only removed that for the environment variable version of the domains (the one used by the CORS extension).

Does this introduce a breaking change?

When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.

[ ] Yes
[X] No

Does this require changes to learn.microsoft.com docs?

This repository is referenced by this tutorial
which includes deployment, settings and usage instructions. If text or screenshot need to change in the tutorial,
check the box below and notify the tutorial author. A Microsoft employee can do this for you if you're an external contributor.

[ ] Yes
[X] No

Type of change

[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

Code quality checklist

See CONTRIBUTING.md for more details.

  • The current tests all pass (python -m pytest).
  • I added tests that prove my fix is effective or that my feature works
  • I ran python -m pytest --cov to verify 100% coverage of added lines
  • I ran python -m mypy to check for type errors
  • I either used the pre-commit hooks or ran ruff and black manually on my code.

AZURE_AUTHENTICATION_ISSUER_URI: authenticationIssuerUri
// CORS support, for frontends on other hosts
ALLOWED_ORIGIN: allowedOriginsEnv
ALLOWED_ORIGIN: join(allowedOrigins, ';')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the variable since this is only used in one place. Generally seems good to avoid excess variables since they might get misused, especially this one that overlaps so closely with other one.

// Filter out any empty origin strings and remove any duplicate origins
var allowedOriginsEnv = join(reduce(filter(allowedOrigins, o => length(trim(o)) > 0), [], (cur, next) => union(cur, [next])), ';')
// Combine custom origins with Microsoft origins, remove any empty origin strings and remove any duplicate origins
var allowedOrigins = reduce(filter(union(split(allowedOrigin, ';'), allMsftAllowedOrigins), o => length(trim(o)) > 0), [], (cur, next) => union(cur, [next]))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay functional programming!

@pamelafox
Copy link
Collaborator Author

FYI, this change is still a good change, but I'm still getting a funky logout experience, so am not marking those issues as resolved.

@pamelafox pamelafox merged commit 1be8653 into Azure-Samples:main Dec 2, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants