aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Common/CommonExtensions.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-10-30 18:50:33 -0500
committerGitHub <noreply@github.com>2022-10-30 18:50:33 -0500
commitea845d19fd3bf1acca08f1062526d1cfe90716f9 (patch)
tree238f9ebc9215dddb0517b2311372ce25f17aff85 /src/slskd/Common/CommonExtensions.cs
parent5c19d4fd6a7eb98d83a5f8c7e2c3092cb2b3b62a (diff)
parent093763beaea0f891410f83febea67b22005bd406 (diff)
downloadslskd-ea845d19fd3bf1acca08f1062526d1cfe90716f9.tar.gz
Merge pull request #717 from slskd/tls
Rework API authentication
Diffstat (limited to 'src/slskd/Common/CommonExtensions.cs')
-rw-r--r--src/slskd/Common/CommonExtensions.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs
index 9cf80a4a..29383fcb 100644
--- a/src/slskd/Common/CommonExtensions.cs
+++ b/src/slskd/Common/CommonExtensions.cs
@@ -20,6 +20,7 @@ namespace slskd
using System;
using System.Collections;
using System.Collections.Generic;
+ using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Linq;
using System.Numerics;
@@ -178,6 +179,14 @@ namespace slskd
}
/// <summary>
+ /// Serializes the JWT.
+ /// </summary>
+ /// <param name="jwt">The JWT.</param>
+ /// <returns>The serialized string.</returns>
+ public static string Serialize(this JwtSecurityToken jwt)
+ => new JwtSecurityTokenHandler().WriteToken(jwt);
+
+ /// <summary>
/// Formats byte to nearest size (KB, MB, etc.)
/// </summary>
/// <param name="value">The value to format.</param>