Add authmethod config value for oidc providers (#453)

This commit is contained in:
Zoe Roux
2024-04-30 00:22:25 +02:00
committed by GitHub
parent 5f20d9102f
commit e1f1106c8d
4 changed files with 47 additions and 6 deletions
@@ -67,6 +67,13 @@ public class PermissionOption
public Dictionary<string, OidcProvider> OIDC { get; set; }
}
public enum AuthMethod
{
ClientSecretBasic,
ClientSecretPost,
None,
}
public class OidcProvider
{
public string DisplayName { get; set; }
@@ -79,6 +86,11 @@ public class OidcProvider
/// </summary>
public bool TokenUseJsonBody { get; set; }
/// <summary>
/// The OIDC spec allows multiples ways of authorizing the client.
/// </summary>
public AuthMethod ClientAuthMethod { get; set; } = AuthMethod.ClientSecretBasic;
public string ProfileUrl { get; set; }
public string? Scope { get; set; }
public string ClientId { get; set; }
@@ -108,6 +120,7 @@ public class OidcProvider
ClientId = KnownProviders[provider].ClientId;
Secret = KnownProviders[provider].Secret;
TokenUseJsonBody = KnownProviders[provider].TokenUseJsonBody;
ClientAuthMethod = KnownProviders[provider].ClientAuthMethod;
GetProfileUrl = KnownProviders[provider].GetProfileUrl;
GetExtraHeaders = KnownProviders[provider].GetExtraHeaders;
}
@@ -144,6 +157,7 @@ public class OidcProvider
// does not seems to have scopes
Scope = null,
TokenUseJsonBody = true,
ClientAuthMethod = AuthMethod.ClientSecretPost,
GetProfileUrl = (profile) => $"https://simkl.com/{profile.Sub}/dashboard/",
GetExtraHeaders = (OidcProvider self) =>
new() { ["simkl-api-key"] = self.ClientId },