diff options
author | crupest <crupest@outlook.com> | 2021-04-28 16:55:37 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-04-28 16:55:37 +0800 |
commit | 344d189e5860a20ebe42cec03b86974a2a3aaa95 (patch) | |
tree | c3958d2ea965c0f31a498501ffe6ab77ed8e35ad /BackEnd/Timeline/Services/Token/IUserTokenHandler.cs | |
parent | d4d0836279f83bbd3d0f47873cd1e182e4459e65 (diff) | |
download | timeline-344d189e5860a20ebe42cec03b86974a2a3aaa95.tar.gz timeline-344d189e5860a20ebe42cec03b86974a2a3aaa95.tar.bz2 timeline-344d189e5860a20ebe42cec03b86974a2a3aaa95.zip |
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Services/Token/IUserTokenHandler.cs')
-rw-r--r-- | BackEnd/Timeline/Services/Token/IUserTokenHandler.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/Token/IUserTokenHandler.cs b/BackEnd/Timeline/Services/Token/IUserTokenHandler.cs new file mode 100644 index 00000000..d9788909 --- /dev/null +++ b/BackEnd/Timeline/Services/Token/IUserTokenHandler.cs @@ -0,0 +1,28 @@ +using System;
+
+namespace Timeline.Services.Token
+{
+ public interface IUserTokenHandler
+ {
+ /// <summary>
+ /// Create a token for a given token info.
+ /// </summary>
+ /// <param name="tokenInfo">The info to generate token.</param>
+ /// <returns>Return the generated token.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="tokenInfo"/> is null.</exception>
+ string GenerateToken(UserTokenInfo tokenInfo);
+
+ /// <summary>
+ /// Verify a token and get the saved info. Do not validate lifetime!!!
+ /// </summary>
+ /// <param name="token">The token to verify.</param>
+ /// <returns>The saved info in token.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="token"/> is null.</exception>
+ /// <exception cref="UserTokenBadFormatException">Thrown when the token is of bad format.</exception>
+ /// <remarks>
+ /// If this method throw <see cref="UserTokenBadFormatException"/>, it usually means the token is not created by this service.
+ /// Do not check expire time in this method, only check whether it is present.
+ /// </remarks>
+ UserTokenInfo VerifyToken(string token);
+ }
+}
|