Skip to content
This repository was archived by the owner on Feb 23, 2025. It is now read-only.

Commit 06fcf23

Browse files
first cut (#329)
1 parent 1e0889e commit 06fcf23

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/OidcClient/OidcClient.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ public virtual async Task<LoginResult> ProcessResponseAsync(
234234
}
235235
}
236236

237-
var user = ProcessClaims(result.User, userInfoClaims);
238-
239-
var authTimeValue = result.TokenResponse.TryGet(JwtClaimTypes.AuthenticationTime);
237+
var authTimeValue = result.User.FindFirst(JwtClaimTypes.AuthenticationTime)?.Value;
240238
DateTimeOffset? authTime = null;
241239

242240
if (authTimeValue.IsPresent() && long.TryParse(authTimeValue, out long seconds))
243241
{
244242
authTime = DateTimeOffset.FromUnixTimeSeconds(seconds);
245243
}
246244

245+
var user = ProcessClaims(result.User, userInfoClaims);
246+
247247
var loginResult = new LoginResult
248248
{
249249
User = user,

test/OidcClient.Tests/CodeFlowResponseTests.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public async Task Valid_response_with_id_token_should_succeed()
5858
var url = $"?state={state.State}&code=bar";
5959
var idToken = Crypto.CreateJwt(null, "https://authority", "client",
6060
new Claim("at_hash", Crypto.HashData("token")),
61-
new Claim("sub", "123"));
61+
new Claim("sub", "123"),
62+
new Claim("auth_time", "123"));
6263

6364
var tokenResponse = new Dictionary<string, object>
6465
{
@@ -77,6 +78,7 @@ public async Task Valid_response_with_id_token_should_succeed()
7778
result.AccessToken.Should().Be("token");
7879
result.IdentityToken.Should().NotBeNull();
7980
result.User.Should().NotBeNull();
81+
result.AuthenticationTime.Should().Be(DateTimeOffset.FromUnixTimeSeconds(123));
8082

8183
result.User.Claims.Count().Should().Be(1);
8284
result.User.Claims.First().Type.Should().Be("sub");

0 commit comments

Comments
 (0)