-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClaimScopesController.cs
More file actions
77 lines (67 loc) · 3.05 KB
/
Copy pathClaimScopesController.cs
File metadata and controls
77 lines (67 loc) · 3.05 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using redb.Identity.Contracts.ClaimMappers;
using redb.Identity.Contracts.Common;
using redb.Identity.Contracts.Routes;
using redb.Route.Controllers.Attributes;
namespace redb.Identity.Http.Controllers;
/// <summary>
/// H5 (v1.0 DoD §5): REST admin API for reusable Client Scopes (mapper bundles)
/// AND for Application↔Scope assignments.
/// Forwards to <c>direct-vm://identity-manage-claim-scopes</c>.
/// </summary>
[Route("claim-scopes")]
public class ClaimScopesController : IdentityControllerBase
{
[HttpGet]
public async Task<object?> List(
[FromQuery("offset")] int offset = 0,
[FromQuery("count")] int count = 25)
=> await Forward(IdentityEndpoints.ManageClaimScopes, "list",
new ListRequest { Offset = offset, Count = count });
[HttpGet("{id}")]
public async Task<object?> Get([FromRoute("id")] string id)
=> await Forward(IdentityEndpoints.ManageClaimScopes, "read", ParseIdBody(id, stringKey: "name"));
[HttpPost]
public async Task<object?> Create([FromBody] CreateClaimScopeRequest request)
{
if (ValidateRequest(request) is { } problem) return problem;
return await Forward(IdentityEndpoints.ManageClaimScopes, "create", request);
}
[HttpPut("{id}")]
public async Task<object?> Update([FromRoute("id")] string id, [FromBody] UpdateClaimScopeRequest request)
{
request.Id = id;
if (ValidateRequest(request) is { } problem) return problem;
return await Forward(IdentityEndpoints.ManageClaimScopes, "update", request);
}
[HttpDelete("{id}")]
public async Task<object?> Delete([FromRoute("id")] string id)
=> await Forward(IdentityEndpoints.ManageClaimScopes, "delete", ParseIdBody(id, stringKey: "name"));
// ── Application ↔ Scope assignments ──
/// <summary>Lists scopes assigned to a given Application.</summary>
[HttpGet("assignments")]
public async Task<object?> ListAssignments([FromQuery("applicationId")] string applicationId)
{
var body = new Dictionary<string, object?> { ["applicationId"] = applicationId };
return await Forward(IdentityEndpoints.ManageClaimScopes, "list-assignments", body);
}
/// <summary>Assigns a scope to an Application (idempotent; returns existing on duplicate).</summary>
[HttpPost("assignments")]
public async Task<object?> Assign([FromBody] AssignClaimScopeRequest request)
{
if (ValidateRequest(request) is { } problem) return problem;
return await Forward(IdentityEndpoints.ManageClaimScopes, "assign", request);
}
/// <summary>Removes a scope assignment by composite key.</summary>
[HttpDelete("assignments")]
public async Task<object?> Unassign(
[FromQuery("applicationId")] string applicationId,
[FromQuery("scopeId")] string scopeId)
{
var body = new Dictionary<string, object?>
{
["applicationId"] = applicationId,
["scopeId"] = scopeId,
};
return await Forward(IdentityEndpoints.ManageClaimScopes, "unassign", body);
}
}