Validate OAuth authorization state (#1726)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Stephen Halter 2026-07-27 12:24:02 -07:00 • committed by GitHub
commit 9c635ffed1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -360,9 +360,10 @@ static async Task<AuthorizationResult?> HandleAuthorizationUrlAsync(
if (location is not null && !string.IsNullOrEmpty(location.Query))
{
// Parse query string to extract "code" and "iss" parameters
// Parse query string to extract "code", "state", and "iss" parameters
var query = location.Query.TrimStart('?');
string? code = null;
string? state = null;
string? iss = null;
foreach (var pair in query.Split('&'))
{
@ -373,6 +374,10 @@ static async Task<AuthorizationResult?> HandleAuthorizationUrlAsync(
{
code = HttpUtility.UrlDecode(parts[1]);
}
else if (parts[0] == "state")
{
state = HttpUtility.UrlDecode(parts[1]);
}
else if (parts[0] == "iss")
{
iss = HttpUtility.UrlDecode(parts[1]);
@ -382,7 +387,7 @@ static async Task<AuthorizationResult?> HandleAuthorizationUrlAsync(
if (code is not null)
{
return new AuthorizationResult { Code = code, Iss = iss };
return new AuthorizationResult { Code = code, State = state, Iss = iss };
}
}