-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMeConsentsController.cs
More file actions
44 lines (40 loc) · 1.78 KB
/
Copy pathMeConsentsController.cs
File metadata and controls
44 lines (40 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using redb.Identity.Contracts.Consents;
using redb.Identity.Contracts.Routes;
using redb.Route.Controllers.Attributes;
namespace redb.Identity.Http.Controllers;
/// <summary>
/// H3 (v1.0 DoD §6): self-service consent management at
/// <c>/api/v1/identity/me/consents</c>. Returns / revokes the caller's own valid
/// permanent OAuth/OIDC consent grants. Caller id is taken from the access-token
/// subject; admins manage consents for other users via <c>/users/{id}/consents</c>.
/// Auth: Bearer with <c>identity:manage</c> or <c>identity:account</c> scope.
/// </summary>
[Route("me/consents")]
public class MeConsentsController : IdentityControllerBase
{
/// <summary>List the caller's valid permanent consent grants.</summary>
[HttpGet]
public async Task<object?> List()
{
return await Forward(IdentityEndpoints.MeConsents, "list",
new Dictionary<string, object?>());
}
/// <summary>Revoke the caller's permanent consent grant for a single client.</summary>
[HttpDelete("{clientId}")]
public async Task<object?> Revoke([FromRoute("clientId")] string clientId)
{
return await Forward(IdentityEndpoints.MeConsents, "revoke",
new MeRevokeConsentRequest { ClientId = clientId });
}
/// <summary>
/// Grant or extend the caller's permanent consent for an application. Used by native
/// consent UIs (e.g. the BFF Razor page) after the user approves a <c>consent_required</c>
/// dialog raised by <c>/connect/authorize</c>. Existing valid permanent grants are
/// merged (union of scopes) rather than replaced.
/// </summary>
[HttpPost]
public async Task<object?> Grant([FromBody] GrantMyConsentRequest request)
{
return await Forward(IdentityEndpoints.MeConsents, "grant", request);
}
}