Validate OAuth authorization state (#1726)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
950ac7c1bc
commit
9c635ffed1
1 changed files with 170 additions and 26 deletions
|
|
@ -28,6 +28,7 @@ public sealed class Program
|
|||
private readonly ConcurrentDictionary<string, ClientInfo> _clients = new();
|
||||
|
||||
private readonly ConcurrentQueue<string> _metadataRequests = new();
|
||||
private int _authorizationCodeTokenRequestCount;
|
||||
|
||||
private readonly RSA _rsa;
|
||||
private readonly string _keyId;
|
||||
|
|
@ -137,6 +138,9 @@ public sealed class Program
|
|||
public HashSet<string> DisabledMetadataPaths { get; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
public IReadOnlyCollection<string> MetadataRequests => _metadataRequests.ToArray();
|
||||
|
||||
/// <summary>Gets the number of authorization-code token exchange requests received.</summary>
|
||||
public int AuthorizationCodeTokenRequestCount => Volatile.Read(ref _authorizationCodeTokenRequestCount);
|
||||
|
||||
/// <summary>Gets the <c>scope</c> field from the most recent Dynamic Client Registration request.</summary>
|
||||
public string? LastRegistrationScope { get; private set; }
|
||||
|
||||
|
|
@ -460,6 +464,7 @@ public sealed class Program
|
|||
|
||||
if (grant_type == "authorization_code")
|
||||
{
|
||||
Interlocked.Increment(ref _authorizationCodeTokenRequestCount);
|
||||
var code = form["code"].ToString();
|
||||
var code_verifier = form["code_verifier"].ToString();
|
||||
var redirect_uri = form["redirect_uri"].ToString();
|
||||
|
|
|
|||
Loading…
Reference in a new issue