Skip to content

Commit 9c9c709

Browse files
authored
Map family_name mapping to surname for Keycloak (#1112)
1 parent 2e9fe18 commit 9c9c709

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/AspNet.Security.OAuth.Keycloak/KeycloakAuthenticationOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public KeycloakAuthenticationOptions()
3131
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub");
3232
ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
3333
ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name");
34+
ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name");
3435
ClaimActions.MapJsonKey(ClaimTypes.Role, "roles");
3536
}
3637

test/AspNet.Security.OAuth.Providers.Tests/Keycloak/KeycloakTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu
2424
[InlineData(ClaimTypes.NameIdentifier, "995c1500-0dca-495e-ba72-2499d370d181")]
2525
[InlineData(ClaimTypes.Email, "[email protected]")]
2626
[InlineData(ClaimTypes.GivenName, "John")]
27+
[InlineData(ClaimTypes.Surname, "Smith")]
2728
[InlineData(ClaimTypes.Role, "admin")]
2829
[InlineData(ClaimTypes.Name, "John Smith")]
2930
public async Task Can_Sign_In_Using_Keycloak_BaseAddress(string claimType, string claimValue)
@@ -44,6 +45,7 @@ static void ConfigureServices(IServiceCollection services)
4445
[InlineData(null, ClaimTypes.NameIdentifier, "995c1500-0dca-495e-ba72-2499d370d181")]
4546
[InlineData(null, ClaimTypes.Email, "[email protected]")]
4647
[InlineData(null, ClaimTypes.GivenName, "John")]
48+
[InlineData(null, ClaimTypes.Surname, "Smith")]
4749
[InlineData(null, ClaimTypes.Role, "admin")]
4850
[InlineData(null, ClaimTypes.Name, "John Smith")]
4951
[InlineData("17.0", ClaimTypes.NameIdentifier, "995c1500-0dca-495e-ba72-2499d370d181")]
@@ -84,6 +86,7 @@ void ConfigureServices(IServiceCollection services)
8486
[InlineData(ClaimTypes.NameIdentifier, "995c1500-0dca-495e-ba72-2499d370d181")]
8587
[InlineData(ClaimTypes.Email, "[email protected]")]
8688
[InlineData(ClaimTypes.GivenName, "John")]
89+
[InlineData(ClaimTypes.Surname, "Smith")]
8790
[InlineData(ClaimTypes.Role, "admin")]
8891
[InlineData(ClaimTypes.Name, "John Smith")]
8992
public async Task Can_Sign_In_Using_Keycloak_Public_AccessType(string claimType, string claimValue)

test/AspNet.Security.OAuth.Providers.Tests/Keycloak/bundle.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"roles": "admin",
2222
"name": "John Smith",
2323
"given_name": "John",
24+
"family_name": "Smith",
2425
"email": "[email protected]"
2526
}
2627
},
@@ -44,6 +45,7 @@
4445
"roles": "admin",
4546
"name": "John Smith",
4647
"given_name": "John",
48+
"family_name": "Smith",
4749
"email": "[email protected]"
4850
}
4951
},
@@ -67,6 +69,7 @@
6769
"roles": "admin",
6870
"name": "John Smith",
6971
"given_name": "John",
72+
"family_name": "Smith",
7073
"email": "[email protected]"
7174
}
7275
}

0 commit comments

Comments
 (0)