summaryrefslogtreecommitdiffstats
path: root/src/server/Api/V1/BaseV1Route.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Api/V1/BaseV1Route.cs')
-rw-r--r--src/server/Api/V1/BaseV1Route.cs17
1 files changed, 17 insertions, 0 deletions
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;
+
+/// <inheritdoc />
+[Authorize(AuthenticationSchemes = AuthSchemes)]
+[ApiController]
+public class BaseV1Route : ControllerBase
+{
+ private const string AuthSchemes = CookieAuthenticationDefaults.AuthenticationScheme + "," + Constants.BASIC_AUTH_SCHEME;
+
+ /// <summary>
+ /// User data for the currently logged on user.
+ /// </summary>
+ protected LoggedInV1User LoggedInUser => new() {
+ Username = User.Identity?.Name,
+ Id = User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value.ToGuid() ?? default
+ };
+}