Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
60dd852
pp
Mu4all Aug 16, 2024
0d86a3f
Preserve original roles claim and allow session context updates
Mu4all Aug 20, 2024
bc468ed
Revert "pp"
Mu4all Aug 20, 2024
ab4fe75
Adjust the relevant tests
Mu4all Aug 21, 2024
93a27dc
Add recordcount
Mu4all Sep 3, 2024
ec0365b
Update src/Core/Resolvers/MsSqlQueryExecutor.cs
M4Al Aug 30, 2024
2cecda7
Update dockerfile to .net8
Mu4all Sep 4, 2024
de8752e
Rename FIRST_URL constant value from "$first" to "$top"
Mu4all Sep 5, 2024
bebd9d2
Rebase fixes
RubenCerna2079 May 23, 2025
773f772
Fixed Dockerfile
RubenCerna2079 May 23, 2025
7de589a
Merge branch 'main' into fix_context_sql
RubenCerna2079 May 23, 2025
bf0bc9c
Merge branch 'main' into fix_context_sql
RubenCerna2079 Jun 16, 2025
9803298
Remove changes from DW SQL Builder
RubenCerna2079 Jun 16, 2025
60859a1
Fix unit test failure
RubenCerna2079 Jun 17, 2025
97ac4c9
Fix Unit Test Failure
RubenCerna2079 Jun 17, 2025
4b5123b
Merge branch 'main' into fix_context_sql
RubenCerna2079 Jun 17, 2025
57e8e5c
Merge branch 'main' into fix_context_sql
RubenCerna2079 Jun 18, 2025
5a77e68
Merge branch 'main' into fix_context_sql
Aniruddh25 Jun 27, 2025
e68fbc4
Merge branch 'main' into fix_context_sql
Aniruddh25 Jul 2, 2025
65970cb
Merge branch 'main' into fix_context_sql
Aniruddh25 Jul 4, 2025
d40e1a5
Merge branch 'main' into fix_context_sql
RubenCerna2079 Aug 11, 2025
db82352
Delete record count
RubenCerna2079 Aug 12, 2025
5c51483
Merge branch 'main' into fix_context_sql
Aniruddh25 Aug 15, 2025
252f1e4
Merge branch 'main' into fix_context_sql
souvikghosh04 Aug 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Config/ObjectModel/AuthenticationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public record AuthenticationOptions(string Provider = nameof(EasyAuthType.Static
public const string CLIENT_PRINCIPAL_HEADER = "X-MS-CLIENT-PRINCIPAL";
public const string NAME_CLAIM_TYPE = "name";
public const string ROLE_CLAIM_TYPE = "roles";
public const string ORIGINAL_ROLE_CLAIM_TYPE = "original_roles";

/// <summary>
/// Returns whether the configured Provider matches an
Expand Down
7 changes: 6 additions & 1 deletion src/Core/Authorization/AuthorizationResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,14 @@ public static Dictionary<string, List<Claim>> GetAllAuthenticatedUserClaims(Http
// into a list and storing that in resolvedClaims using the claimType as the key.
foreach (Claim claim in identity.Claims)
{
// 'roles' claim has already been processed.
// 'roles' claim has already been processed. But we preserve the original 'roles' claim.
if (claim.Type.Equals(AuthenticationOptions.ROLE_CLAIM_TYPE))
{
if (!resolvedClaims.TryAdd(AuthenticationOptions.ORIGINAL_ROLE_CLAIM_TYPE, new List<Claim>() { claim }))
{
resolvedClaims[AuthenticationOptions.ORIGINAL_ROLE_CLAIM_TYPE].Add(claim);
}

continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Resolvers/MsSqlQueryExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public override string GetSessionParamsQuery(HttpContext? httpContext, IDictiona
string paramName = $"{SESSION_PARAM_NAME}{counter.Next()}";
parameters.Add(paramName, new(claimValue));
// Append statement to set read only param value - can be set only once for a connection.
string statementToSetReadOnlyParam = "EXEC sp_set_session_context " + $"'{claimType}', " + paramName + ", @read_only = 1;";
string statementToSetReadOnlyParam = "EXEC sp_set_session_context " + $"'{claimType}', " + paramName + ", @read_only = 0;";
sessionMapQuery = sessionMapQuery.Append(statementToSetReadOnlyParam);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,8 @@ public void UniqueClaimsResolvedForDbPolicy_SessionCtx_Usage()
new("sub", "Aa_0RISCzzZ-abC1De2fGHIjKLMNo123pQ4rStUVWXY"),
new("oid", "55296aad-ea7f-4c44-9a4c-bb1e8d43a005"),
new(AuthenticationOptions.ROLE_CLAIM_TYPE, TEST_ROLE),
new(AuthenticationOptions.ROLE_CLAIM_TYPE, "ROLE2")
new(AuthenticationOptions.ROLE_CLAIM_TYPE, "ROLE2"),
new(AuthenticationOptions.ROLE_CLAIM_TYPE, "ROLE3")
};

//Add identity object to the Mock context object.
Expand All @@ -1315,6 +1316,7 @@ public void UniqueClaimsResolvedForDbPolicy_SessionCtx_Usage()
Assert.AreEqual(expected: "Aa_0RISCzzZ-abC1De2fGHIjKLMNo123pQ4rStUVWXY", actual: claimsInRequestContext["sub"], message: "Expected the sub claim to be present.");
Assert.AreEqual(expected: "55296aad-ea7f-4c44-9a4c-bb1e8d43a005", actual: claimsInRequestContext["oid"], message: "Expected the oid claim to be present.");
Assert.AreEqual(claimsInRequestContext[AuthenticationOptions.ROLE_CLAIM_TYPE], actual: TEST_ROLE, message: "The roles claim should have the value:" + TEST_ROLE);
Assert.AreEqual(expected: "[\"" + TEST_ROLE + "\",\"ROLE2\",\"ROLE3\"]", actual: claimsInRequestContext[AuthenticationOptions.ORIGINAL_ROLE_CLAIM_TYPE], message: "Original roles should be preserved in a new context");
}

/// <summary>
Expand Down Expand Up @@ -1365,7 +1367,7 @@ public void ValidateUnauthenticatedUserClaimsAreNotResolvedWhenProcessingUserCla
Dictionary<string, string> resolvedClaims = AuthorizationResolver.GetProcessedUserClaims(context.Object);

// Assert
Assert.AreEqual(expected: authenticatedUserclaims.Count, actual: resolvedClaims.Count, message: "Only two claims should be present.");
Assert.AreEqual(expected: authenticatedUserclaims.Count + 1, actual: resolvedClaims.Count, message: "Only " + (authenticatedUserclaims.Count + 1) + " claims should be present.");
Assert.AreEqual(expected: "openid", actual: resolvedClaims["scp"], message: "Unexpected scp claim returned.");

bool didResolveUnauthenticatedRoleClaim = resolvedClaims[AuthenticationOptions.ROLE_CLAIM_TYPE] == "Don't_Parse_This_Role";
Expand Down
Loading