yavsc/src/Yavsc.Server/Config.cs

89 lines
3.3 KiB
C#
Raw Normal View History

2024-11-06 13:00:34 +00:00

2025-02-08 20:06:24 +00:00
using IdentityServer8;
using IdentityServer8.Models;
2025-02-14 00:20:35 +00:00
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
2024-02-25 18:05:10 +00:00
using Yavsc.Settings;
2024-02-14 20:35:15 +00:00
namespace Yavsc;
public static class Config
{
2026-02-22 23:39:56 +00:00
public static string Authority { get; set; }
2024-02-25 18:05:10 +00:00
public static IConfigurationRoot? GoogleWebClientConfiguration { get; set; }
public static GoogleServiceAccount? GServiceAccount { get; set; }
2025-03-04 18:05:21 +00:00
public static SiteSettings SiteSetup { get; set; } = new SiteSettings();
public static FileServerOptions? UserFilesOptions { get; set; }
public static FileServerOptions? GitOptions { get; set; }
public static string AvatarsDirName { set; get; } = "Avatars";
public static string GitDirName { set; get; } = "Git";
2024-02-25 18:05:10 +00:00
2025-03-04 18:05:21 +00:00
public static GoogleAuthSettings? GoogleSettings { get; set; }
public static SmtpSettings? SmtpSetup { get; set; }
public static string? Temp { get; set; }
public static FileServerOptions? AvatarsOptions { get; set; }
public static string UserBillsDirName { set; get; } = "Bills";
public static string UserFilesDirName { set; get; } = "Files";
2024-02-25 18:05:10 +00:00
/// <summary>
/// Lists Available user profile classes,
2025-07-15 17:35:14 +01:00
/// populated at startup, using reflection.
2024-02-25 18:05:10 +00:00
/// </summary>
public static List<Type> ProfileTypes = new List<Type>();
2024-02-14 20:35:15 +00:00
public static IEnumerable<IdentityResource> IdentityResources =>
2025-07-15 17:35:14 +01:00
[
2024-02-14 20:35:15 +00:00
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
2025-02-09 12:04:14 +00:00
new IdentityResources.Email()
2025-07-15 17:35:14 +01:00
];
2024-02-14 20:35:15 +00:00
2025-08-24 16:07:53 +01:00
public static IEnumerable<ApiScope> ApiScopes =>
2025-07-15 17:35:14 +01:00
[
2025-02-15 20:10:01 +00:00
new ApiScope("scope1",new string[] {"scope1"}),
new ApiScope("scope2",new string[] {"scope2"}),
2025-07-15 17:35:14 +01:00
];
2024-02-14 20:35:15 +00:00
2025-08-24 16:07:53 +01:00
public static IEnumerable<Client> Clients =>
2025-07-15 17:35:14 +01:00
[
2024-02-14 20:35:15 +00:00
// m2m client credentials flow client
new Client
{
ClientId = "m2m.client",
ClientName = "Client Credentials Client",
ClientSecrets = { new Secret("511536EF-F270-4058-80CA-1C89C192F69A".Sha256()) },
2025-07-30 15:49:15 +01:00
AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
2024-02-14 20:35:15 +00:00
AllowedScopes = { "scope1" }
},
// interactive client using code flow + pkce
new Client
{
2025-02-08 20:06:24 +00:00
ClientId = "mvc",
2024-02-14 20:35:15 +00:00
ClientSecrets = { new Secret("49C1A7E1-0C79-4A89-A3D6-A37998FB86B0".Sha256()) },
AllowedGrantTypes = GrantTypes.Code,
2025-02-16 22:40:51 +00:00
AlwaysIncludeUserClaimsInIdToken = true,
2024-02-14 20:35:15 +00:00
2025-02-08 20:06:24 +00:00
RedirectUris = { "https://localhost:5003/signin-oidc",
"http://localhost:5002/signin-oidc" },
2025-02-26 19:44:54 +00:00
PostLogoutRedirectUris = { "https://localhost:5003/signout-callback-oidc",
"http://localhost:5002/signout-callback-oidc" },
2025-02-11 04:45:05 +00:00
2025-07-07 07:49:18 +01:00
AllowedScopes = {
2025-02-08 20:06:24 +00:00
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
2025-02-09 16:57:10 +00:00
IdentityServerConstants.StandardScopes.Email,
2025-02-11 04:45:05 +00:00
IdentityServerConstants.StandardScopes.OfflineAccess,
2025-07-07 07:49:18 +01:00
"scope2" },
2024-02-14 20:35:15 +00:00
},
2025-07-15 17:35:14 +01:00
];
2024-02-25 18:05:10 +00:00
2025-03-04 18:05:21 +00:00
public static PayPalSettings? PayPalSettings { get; set; }
2024-02-14 20:35:15 +00:00
}