Skip to content

Commit 51236a1

Browse files
committed
now you can also use the UPN in applicaitons
1 parent 6b65126 commit 51236a1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/KK.AspNetCore.EasyAuthAuthentication.Test/Services/EasyAuthForAuthorizationTokenServiceTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ public void IfAValidJwtTokenWithoutIdpPropertyIsInTheHeaderTheResultIsSuccsess()
8585
Assert.Equal(this.testJwtAppId, result.Principal.Identity.Name);
8686
}
8787

88+
[Fact]
89+
public void IfAValidJwtTokenWithAnUpnPropertyIsInTheHeaderTheResultContainsTheUpnAsIdentity()
90+
{
91+
// Arrange
92+
var handler = new EasyAuthForAuthorizationTokenService(this.loggerFactory.CreateLogger<EasyAuthForAuthorizationTokenService>());
93+
var httpcontext = new DefaultHttpContext();
94+
var jwtWithoutIdpProperty = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIwN2Q2ZDE1YS1jZTg5LTQ4MmMtOTcxYi01NDMxYjc1MTkxNjciLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lOTgxZGNhZi05MTk3LTQ3N2YtYmQwNi0wZTU3MmIwYjMzNDcvIiwiaWF0IjoxNTYyNjk4ODc2LCJuYmYiOjE1NjI2OTg4NzYsImV4cCI6MTU2MjcwMjc3NiwiYWlvIjoiNDJaZ1lPQmZzRzd0ZEg1ZVBpSHZvNU9QdDdyT0J3QT0iLCJhcHBpZCI6ImQzMTViZmFmLTYzMDQtNGY5Zi04MjFjLTU0NmJkYzAwYjViMCIsInVwbiI6InRlc3R1c2VyQHRlc3QuZGUiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lOTgxZGNhZi05MTk3LTQ3N2YtYmQwNi0wZTU3MmIwYjMzNDcvIiwib2lkIjoiZjVmOWZhODYtNDQxNC00NGM3LTgwZjgtZjc4MGFlMGFiZjIxIiwicm9sZXMiOlsiU3lzdGVtQWRtaW4iXSwic3ViIjoiZjVmOWZhODYtNDQxNC00NGM3LTgwZjgtZjc4MGFlMGFiZjIxIiwidGlkIjoiZTk4MWRjYWYtOTE5Ny00NzdmLWJkMDYtMGU1NzJiMGIzMzQ3IiwidXRpIjoiaENKdTNvaDd3VWVaYWk1UUpPWUFBQSIsInZlciI6IjEuMCJ9.T2vYwRaOFtISgoaMgg6XJ-pZEA5SOhqW09mF7TsGDBY";
95+
httpcontext.Request.Headers.Add("Authorization", jwtWithoutIdpProperty);
96+
// Act
97+
var result = handler.AuthUser(httpcontext);
98+
// Arrange
99+
Assert.True(result.Succeeded);
100+
Assert.True(result.Principal.HasClaim(ClaimTypes.Role, "SystemAdmin"));
101+
Assert.Equal("testuser@test.de", result.Principal.Identity.Name);
102+
}
103+
88104
[Fact]
89105
public void IfAValidJwtTokenWithoutIdpAndIssPropertyIsInTheHeaderItsThrowsAnError()
90106
{

0 commit comments

Comments
 (0)