aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorSanskar Pandey <sanskarpandey0@gmail.com>2022-10-10 15:00:03 +0530
committerGitHub <noreply@github.com>2022-10-10 15:00:03 +0530
commit9c84200a25ee590e30b5e10d5b9a648ae105730e (patch)
treeaec47cc2bf04ae5ba47be6f6071aaa7c4eef1e6f /src/slskd/Program.cs
parent56bfdfc22b7a2cb9f7270f83498548f93ab4a04e (diff)
parent7c00e16196cb4e21467e6f94f9098de9e48a1219 (diff)
downloadslskd-9c84200a25ee590e30b5e10d5b9a648ae105730e.tar.gz
Merge branch 'master' into contentPath-relative-path
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 7a1e636f..56ab6317 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -132,7 +132,7 @@ namespace slskd
/// <summary>
/// Gets the semantic application version.
/// </summary>
- public static string SemanticVersion { get; } = InformationalVersion.Split('-').First();
+ public static string SemanticVersion { get; } = InformationalVersion.Split('+').First();
/// <summary>
/// Gets the full application version, including both assembly and informational versions.
@@ -602,6 +602,22 @@ namespace slskd
if (!OptionsAtStartup.Web.Authentication.Disabled)
{
+ services.AddAuthorization(options =>
+ {
+ options.AddPolicy(AuthPolicy.JwtOnly, policy =>
+ {
+ policy.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme);
+ policy.RequireAuthenticatedUser();
+ });
+
+ options.AddPolicy(AuthPolicy.Any, policy =>
+ {
+ policy.AuthenticationSchemes.Add(ApiKeyAuthentication.AuthenticationScheme);
+ policy.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme);
+ policy.RequireAuthenticatedUser();
+ });
+ });
+
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
@@ -633,9 +649,7 @@ namespace slskd
return Task.CompletedTask;
},
};
- });
-
- services.AddAuthentication(ApiKeyAuthentication.AuthenticationScheme)
+ })
.AddScheme<ApiKeyAuthenticationOptions, ApiKeyAuthenticationHandler>(ApiKeyAuthentication.AuthenticationScheme, options =>
{
options.EnableSignalRSupport = true;
@@ -647,6 +661,21 @@ namespace slskd
{
Log.Warning("Authentication of web requests is DISABLED");
+ services.AddAuthorization(options =>
+ {
+ options.AddPolicy(AuthPolicy.Any, policy =>
+ {
+ policy.AuthenticationSchemes.Add(PassthroughAuthentication.AuthenticationScheme);
+ policy.RequireAuthenticatedUser();
+ });
+
+ options.AddPolicy(AuthPolicy.JwtOnly, policy =>
+ {
+ policy.AuthenticationSchemes.Add(PassthroughAuthentication.AuthenticationScheme);
+ policy.RequireAuthenticatedUser();
+ });
+ });
+
services.AddAuthentication(PassthroughAuthentication.AuthenticationScheme)
.AddScheme<PassthroughAuthenticationOptions, PassthroughAuthenticationHandler>(PassthroughAuthentication.AuthenticationScheme, options =>
{