From 88110f536f9c3843ecf5016122e101f8a424af77 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 22 Jan 2022 22:43:38 +0100 Subject: Initial commit --- src/server/Api/V1/BaseV1Route.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/server/Api/V1/BaseV1Route.cs (limited to 'src/server/Api/V1/BaseV1Route.cs') diff --git a/src/server/Api/V1/BaseV1Route.cs b/src/server/Api/V1/BaseV1Route.cs new file mode 100644 index 0000000..ba7d978 --- /dev/null +++ b/src/server/Api/V1/BaseV1Route.cs @@ -0,0 +1,17 @@ +namespace IOL.BookmarkThing.Server.Api.V1; + +/// +[Authorize(AuthenticationSchemes = AuthSchemes)] +[ApiController] +public class BaseV1Route : ControllerBase +{ + private const string AuthSchemes = CookieAuthenticationDefaults.AuthenticationScheme + "," + Constants.BASIC_AUTH_SCHEME; + + /// + /// User data for the currently logged on user. + /// + protected LoggedInV1User LoggedInUser => new() { + Username = User.Identity?.Name, + Id = User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value.ToGuid() ?? default + }; +} -- cgit v1.3