diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-24 06:29:23 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-24 06:29:23 +0200 |
| commit | 585c5c8537eb21dfc9f16108548e63d9ced3d971 (patch) | |
| tree | 1582bc45dcab585ec7204f1570019b2ca8de36c5 /code/api/src/Endpoints/V1/BaseRoute.cs | |
| parent | 4b42c5235482fe0d3811b4e2936614c79e20d970 (diff) | |
| download | greatoffice-585c5c8537eb21dfc9f16108548e63d9ced3d971.tar.xz greatoffice-585c5c8537eb21dfc9f16108548e63d9ced3d971.zip | |
feat: Before move to FastEndpoints
Diffstat (limited to 'code/api/src/Endpoints/V1/BaseRoute.cs')
| -rw-r--r-- | code/api/src/Endpoints/V1/BaseRoute.cs | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/code/api/src/Endpoints/V1/BaseRoute.cs b/code/api/src/Endpoints/V1/BaseRoute.cs deleted file mode 100644 index e7d72ac..0000000 --- a/code/api/src/Endpoints/V1/BaseRoute.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Net.Http.Headers; - -namespace IOL.GreatOffice.Api.Endpoints.V1; - -/// <inheritdoc /> -[ApiVersion(ApiSpecV1.VERSION_STRING)] -[Authorize(AuthenticationSchemes = AuthSchemes)] -[ApiController] -public class BaseRoute : ControllerBase -{ - private const string AuthSchemes = CookieAuthenticationDefaults.AuthenticationScheme + "," + AppConstants.BASIC_AUTH_SCHEME; - - /// <summary> - /// User data for the currently logged on user. - /// </summary> - protected LoggedInUserModel LoggedInUser => new() { - Username = User.FindFirstValue(AppClaims.NAME), - Id = User.FindFirstValue(AppClaims.USER_ID).AsGuid(), - }; - - protected bool IsApiCall() { - if (!Request.Headers.ContainsKey("Authorization")) return false; - try { - var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]); - if (authHeader.Parameter == null) return false; - } catch { - return false; - } - - return true; - } - - protected bool HasApiPermission(string permission_key) { - var permission_claim = User.Claims.SingleOrDefault(c => c.Type == permission_key); - return permission_claim is { - Value: "True" - }; - } -} |
