aboutsummaryrefslogtreecommitdiff
path: root/src/Common/DevHive.Common/Jwt/Interfaces/IJwtService.cs
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-02-28 20:52:56 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-02-28 20:52:56 +0200
commit8d604f9e353cf0b8b8302fc6fb71dd4408c937fe (patch)
tree9471b70a01b459c08bf2c1528cb4aba76d781f97 /src/Common/DevHive.Common/Jwt/Interfaces/IJwtService.cs
parentd53d67776f0746cc6eb8973f7c55767fcf82df65 (diff)
parent2a85613d6827f5a1d151b856739863fbe9782143 (diff)
downloadDevHive-8d604f9e353cf0b8b8302fc6fb71dd4408c937fe.tar
DevHive-8d604f9e353cf0b8b8302fc6fb71dd4408c937fe.tar.gz
DevHive-8d604f9e353cf0b8b8302fc6fb71dd4408c937fe.zip
merge with dev
Diffstat (limited to 'src/Common/DevHive.Common/Jwt/Interfaces/IJwtService.cs')
-rw-r--r--src/Common/DevHive.Common/Jwt/Interfaces/IJwtService.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Common/DevHive.Common/Jwt/Interfaces/IJwtService.cs b/src/Common/DevHive.Common/Jwt/Interfaces/IJwtService.cs
new file mode 100644
index 0000000..352a7d5
--- /dev/null
+++ b/src/Common/DevHive.Common/Jwt/Interfaces/IJwtService.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+
+namespace DevHive.Common.Jwt.Interfaces
+{
+ public interface IJwtService
+ {
+ /// <summary>
+ /// The generation of a JWT, when a new user registers or log ins
+ /// Tokens have an expiration time of 7 days.
+ /// </summary>
+ /// <param name="userId">User's Guid</param>
+ /// <param name="username">Users's username</param>
+ /// <param name="roleNames">List of user's roles</param>
+ /// <returns>Return a new JWT, containing the user id, username and roles.</returns>
+ string GenerateJwtToken(Guid userId, string username, List<string> roleNames);
+
+ /// <summary>
+ /// Checks whether the given user, gotten by the "id" property,
+ /// is the same user as the one in the token (unless the user in the token has the admin role)
+ /// and the roles in the token are the same as those in the user, gotten by the id in the token
+ /// </summary>
+ /// <param name="userId">Guid of the user being validated</param>
+ /// <param name="rawToken">The raw token coming from the request</param>
+ /// <returns>Bool result of is the user authenticated to do an action</returns>
+ bool ValidateToken(Guid userId, string rawToken);
+ }
+}