Implement US-13 patient authentication and persistent ownership
This commit is contained in:
1 parent
ebf50827d6
commit
0ce9b2b168
36 files changed
+1203
-28
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace ApiGateway.Controllers;
|
||||
|
||||
@@ -10,6 +11,10 @@ public sealed class PatientController(IHttpClientFactory clients) : ControllerBa
|
||||
public Task CreatePatient(CancellationToken cancellationToken) =>
|
||||
ForwardAsync(HttpMethod.Post, "api/patients", cancellationToken);
|
||||
|
||||
[HttpGet("me")]
|
||||
public Task GetOwnPatient(CancellationToken cancellationToken) =>
|
||||
ForwardAsync(HttpMethod.Get, "api/patients/by-account/" + Uri.EscapeDataString(User.FindFirstValue(ClaimTypes.NameIdentifier)!), cancellationToken);
|
||||
|
||||
[HttpGet("{patientId:guid}")]
|
||||
public Task GetPatient(Guid patientId, CancellationToken cancellationToken) =>
|
||||
ForwardAsync(HttpMethod.Get, $"api/patients/{patientId}", cancellationToken);
|
||||
@@ -21,6 +26,8 @@ public sealed class PatientController(IHttpClientFactory clients) : ControllerBa
|
||||
private async Task ForwardAsync(HttpMethod method, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
using var request = new HttpRequestMessage(method, path);
|
||||
if (method == HttpMethod.Post)
|
||||
request.Headers.Add("X-Account-Id", User.FindFirstValue(ClaimTypes.NameIdentifier));
|
||||
if (method == HttpMethod.Post || method == HttpMethod.Put)
|
||||
{
|
||||
request.Content = new StreamContent(Request.Body);
|
||||
|
||||
Reference in new issue
Block a user