-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScopesController.cs
More file actions
50 lines (44 loc) · 1.65 KB
/
Copy pathScopesController.cs
File metadata and controls
50 lines (44 loc) · 1.65 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
using redb.Identity.Contracts.Common;
using redb.Identity.Contracts.Scopes;
using redb.Identity.Contracts.Routes;
using redb.Route.Controllers.Attributes;
namespace redb.Identity.Http.Controllers;
/// <summary>
/// REST management API for OAuth 2.0 scopes.
/// Forwards to <c>direct-vm://identity-manage-scopes</c> route.
/// </summary>
[Route("scopes")]
public class ScopesController : IdentityControllerBase
{
[HttpGet]
public async Task<object?> List(
[FromQuery("offset")] int offset = 0,
[FromQuery("count")] int count = 25)
{
return await Forward(IdentityEndpoints.ManageScopes, "list",
new ListRequest { Offset = offset, Count = count });
}
[HttpGet("{id}")]
public async Task<object?> Get([FromRoute("id")] string id)
{
return await Forward(IdentityEndpoints.ManageScopes, "read", ParseIdBody(id, stringKey: "name"));
}
[HttpPost]
public async Task<object?> Create([FromBody] CreateScopeRequest request)
{
if (ValidateRequest(request) is { } problem) return problem;
return await Forward(IdentityEndpoints.ManageScopes, "create", request);
}
[HttpPut("{id}")]
public async Task<object?> Update([FromRoute("id")] string id, [FromBody] UpdateScopeRequest request)
{
request.Id = id;
if (ValidateRequest(request) is { } problem) return problem;
return await Forward(IdentityEndpoints.ManageScopes, "update", request);
}
[HttpDelete("{id}")]
public async Task<object?> Delete([FromRoute("id")] string id)
{
return await Forward(IdentityEndpoints.ManageScopes, "delete", ParseIdBody(id, stringKey: "name"));
}
}