Skip to content

Commit

Permalink
Move max age 0 check earlier in pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdecock committed May 31, 2024
1 parent 81bc1b2 commit 845d428
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ protected internal virtual async Task<InteractionResponse> ProcessLoginAsync(Val
return new InteractionResponse { IsLogin = true };
}

if (request.MaxAge == 0)
{
Logger.LogInformation("Showing login: request contains max_age=0.");
// Remove the max_age=0 parameter to prevent (infinite) loop
request.RemoveMaxAge();
return new InteractionResponse { IsLogin = true };
}

// unauthenticated user
var isAuthenticated = request.Subject.IsAuthenticated();

Expand Down Expand Up @@ -244,12 +252,6 @@ protected internal virtual async Task<InteractionResponse> ProcessLoginAsync(Val
var authTime = request.Subject.GetAuthenticationTime();
if (Clock.UtcNow.UtcDateTime > authTime.AddSeconds(request.MaxAge.Value))
{
// Remove the max_age=0 parameter to prevent (infinite) loop
if (request.MaxAge.Value == 0)
{
request.RemoveMaxAge();
}

Logger.LogInformation("Showing login: Requested MaxAge exceeded.");

return new InteractionResponse { IsLogin = true };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ public async Task prompt_login_should_show_login_page_and_preserve_prompt_values

[Fact]
[Trait("Category", Category)]
public async Task max_age_0_should_show_login_page_and_preserve_max_age()
public async Task max_age_0_should_show_login_page()
{
await _mockPipeline.LoginAsync("bob");

Expand Down

0 comments on commit 845d428

Please sign in to comment.