-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[PM-33216] Finalize RequireSsoPolicyRequirement #7173
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
Merged
eliykat
merged 11 commits into
main
from
ac/pm-33216/finalize-implementation-requiresso
Mar 16, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c505b01
Add more efficient sproc for hot path
eliykat 14340bb
Wire up new sproc as vNext method for hot path only
eliykat 0ed7956
Finalize implementation and tests
eliykat a4d874b
Fix tests
eliykat 9e528d7
Remove dead mocks and tests
eliykat 21e6d54
Add null check for query parity
eliykat 22f87fe
dotnet format
eliykat 80e5c52
Merge remote-tracking branch 'origin/main' into ac/pm-33216/finalize-β¦
eliykat 818cdcc
Fix sproc formatting
eliykat 2e51bf2
Fix sproc formatting
eliykat a6bb730
Merge branch 'main' into ac/pm-33216/finalize-implementation-requiresso
eliykat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/Sql/dbo/Stored Procedures/PolicyDetails_ReadByUserIdPolicyType.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| CREATE PROCEDURE [dbo].[PolicyDetails_ReadByUserIdPolicyType] | ||
| @UserId UNIQUEIDENTIFIER, | ||
| @PolicyType TINYINT | ||
| AS | ||
| BEGIN | ||
| SET NOCOUNT ON | ||
|
|
||
| DECLARE @UserEmail NVARCHAR(256) | ||
| SELECT @UserEmail = Email | ||
| FROM | ||
| [dbo].[UserView] | ||
| WHERE | ||
| Id = @UserId | ||
|
|
||
| ;WITH OrgUsers AS | ||
| ( | ||
| -- Non-invited users (Status != 0): direct UserId match | ||
| SELECT | ||
| OU.[Id], | ||
| OU.[OrganizationId], | ||
| OU.[Type], | ||
| OU.[Status], | ||
| OU.[Permissions] | ||
| FROM | ||
| [dbo].[OrganizationUserView] OU | ||
| WHERE | ||
| OU.[Status] != 0 | ||
| AND OU.[UserId] = @UserId | ||
|
|
||
| UNION ALL | ||
|
|
||
| -- Invited users (Status = 0): email match | ||
| SELECT | ||
| OU.[Id], | ||
| OU.[OrganizationId], | ||
| OU.[Type], | ||
| OU.[Status], | ||
| OU.[Permissions] | ||
| FROM | ||
| [dbo].[OrganizationUserView] OU | ||
| WHERE | ||
| OU.[Status] = 0 | ||
| AND OU.[Email] = @UserEmail | ||
| AND @UserEmail IS NOT NULL | ||
| ), | ||
| Providers AS | ||
| ( | ||
| SELECT | ||
| OrganizationId | ||
| FROM | ||
| [dbo].[UserProviderAccessView] | ||
| WHERE | ||
| UserId = @UserId | ||
| ) | ||
| SELECT | ||
| OU.[Id] AS OrganizationUserId, | ||
| P.[OrganizationId], | ||
| P.[Type] AS PolicyType, | ||
| P.[Data] AS PolicyData, | ||
| OU.[Type] AS OrganizationUserType, | ||
| OU.[Status] AS OrganizationUserStatus, | ||
| OU.[Permissions] AS OrganizationUserPermissionsData, | ||
| CASE WHEN PR.[OrganizationId] IS NULL THEN 0 ELSE 1 END AS IsProvider | ||
| FROM | ||
| [dbo].[PolicyView] P | ||
| INNER JOIN | ||
| OrgUsers OU ON P.[OrganizationId] = OU.[OrganizationId] | ||
| INNER JOIN | ||
| [dbo].[OrganizationView] O ON P.[OrganizationId] = O.[Id] | ||
| LEFT JOIN | ||
| Providers PR ON PR.[OrganizationId] = OU.[OrganizationId] | ||
| WHERE | ||
| P.[Type] = @PolicyType | ||
| AND P.[Enabled] = 1 | ||
| AND O.[Enabled] = 1 | ||
| AND O.[UsePolicies] = 1 | ||
| END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review: PR #7173 β Finalize RequireSsoPolicyRequirement
Summary: This PR adds an optimized single-user stored procedure for policy detail queries, wires it through a
GetAsyncVNextmethod, and switches the twoRequireSsoPolicyRequirementconsumers to use it. The approach is sound β keeping the feature flag as a killswitch while optimizing the hot login path. Overall this is a clean, well-structured PR.Findings (all non-blocking):
CanUsePasskeyLoginlogic change (RequireSsoPolicyRequirement.cs:51-54): The oldAll(Revoked||Invited)β new!Any(Accepted||Confirmed)change is logically equivalent sinceEnforcealready filters out Invited/Revoked. The new code is more robust by explicitly naming the disabling statuses. Good change.Dead mock setup in
BaseRequestValidatorTests:551,590: These still mockGetAsync<RequireSsoPolicyRequirement>(notGetAsyncVNext), but since_ssoRequestValidator.ValidateAsyncis also mocked, the mock is never hit. Pre-existing, not introduced by this PR. Cleanup candidate for follow-up.SQL sproc looks correct: CTE with
UNION ALLfor non-invited/invited users,@UserEmail IS NOT NULLguard,LEFT JOINfor providers, proper Enabled/UsePolicies filters. Migration matches sproc (onlyCREATEvsCREATE OR ALTER).EF implementation matches sproc logic: Handles email null-safety correctly (SQL
NULL = NULLβ false), usesHashSetfor provider lookup, consistent filter conditions.Integration tests are thorough: Covers confirmed/accepted/invited users, multiple orgs, policy type filtering, disabled policies/orgs, UsePolicies=false, and provider flag.
Verdict: Looks good. β