Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BannedApiAnalyzers to prevent use of ClaimsIdentity constructors and AppContextSwitches for fallback #2977

Merged
merged 9 commits into from
Aug 21, 2024

Conversation

pmaytak
Copy link
Contributor

@pmaytak pmaytak commented Aug 13, 2024

Use CaseSensitiveClaimsIdentity by default.

Add AppContextSwitches to fallback to using ClaimsIdentity.

Add BannedApiAnalyzers to prevent use of ClaimsIdentity constructors and enforce use of CaseSensitiveClaimsIdentity, which makes claims retrieval consistent.

The disallowed definitions are contained in BannedSymbols.txt. There is no wildcard to include all constructors for a type, so each one has to be added.

If a banned member is used, the following error is thrown:
RS0030 The symbol has been marked as banned in this project, and an alternate should be used instead.

@pmaytak pmaytak added this to the 3.1.0 milestone Aug 20, 2024
@pmaytak pmaytak marked this pull request as ready for review August 20, 2024 08:33
@pmaytak pmaytak requested a review from a team as a code owner August 20, 2024 08:33
@pmaytak pmaytak changed the title Add BannedApiAnalyzers to prevent use of ClaimsIdentity constructors Add BannedApiAnalyzers to prevent use of ClaimsIdentity constructors and AppContextSwitches for fallback Aug 20, 2024
Copy link
Collaborator

@jmprieur jmprieur left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks @pmaytak

Assuming the RequireScopeXXX won't introduce a breaking change as we consume the claims identity ourselves?

Copy link
Collaborator

@jennyf19 jennyf19 left a comment

Choose a reason for hiding this comment

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

:shipit:

@pmaytak pmaytak merged commit 63bc10e into master Aug 21, 2024
5 checks passed
@pmaytak pmaytak deleted the pmaytak/bannedapi branch August 21, 2024 16:15
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.

4 participants