diff options
author | vman <public@vaughnnugent.com> | 2022-12-15 01:41:41 -0500 |
---|---|---|
committer | vman <public@vaughnnugent.com> | 2022-12-15 01:41:41 -0500 |
commit | a5ad943584e91bfbd953dc373a7a313367c7e0ae (patch) | |
tree | 5d5c63f6c04e3e87dec3b8fec3662d39b7b954d0 /VNLib.Plugins.Essentials.SocialOauth/Endpoints/GitHubOauth.cs | |
parent | f13193aa928f099c8152653570d2839b46b8f1ee (diff) |
Mfa/login fixes
Diffstat (limited to 'VNLib.Plugins.Essentials.SocialOauth/Endpoints/GitHubOauth.cs')
-rw-r--r-- | VNLib.Plugins.Essentials.SocialOauth/Endpoints/GitHubOauth.cs | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/VNLib.Plugins.Essentials.SocialOauth/Endpoints/GitHubOauth.cs b/VNLib.Plugins.Essentials.SocialOauth/Endpoints/GitHubOauth.cs index 0b4fc0f..676f2bb 100644 --- a/VNLib.Plugins.Essentials.SocialOauth/Endpoints/GitHubOauth.cs +++ b/VNLib.Plugins.Essentials.SocialOauth/Endpoints/GitHubOauth.cs @@ -39,8 +39,6 @@ using VNLib.Plugins.Essentials.Accounts; using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Loading.Users; -#nullable enable - namespace VNLib.Plugins.Essentials.SocialOauth.Endpoints { [ConfigurationName("github")] @@ -49,32 +47,38 @@ namespace VNLib.Plugins.Essentials.SocialOauth.Endpoints private const string GITHUB_V3_ACCEPT = "application/vnd.github.v3+json"; private readonly string UserEmailUrl; - + protected override OauthClientConfig Config { get; } public GitHubOauth(PluginBase plugin, IReadOnlyDictionary<string, JsonElement> config) : base() { - //Get id/secret - Task<string?> secret = plugin.TryGetSecretAsync("github_client_secret"); - Task<string?> clientId = plugin.TryGetSecretAsync("github_client_id"); - - //Wait sync - Task.WaitAll(secret, clientId); + + UserEmailUrl = config["user_email_url"].GetString() ?? throw new KeyNotFoundException("Missing required key 'user_email_url' for github configuration"); - Config = new(configName: "github", config) + Config = new("github", config) { - //get gh client secret and id - ClientID = clientId.Result ?? throw new KeyNotFoundException("Missing Github client id from config or vault"), - ClientSecret = secret.Result ?? throw new KeyNotFoundException("Missing Github client secret from config or vault"), - Passwords = plugin.GetPasswords(), Users = plugin.GetUserManager(), }; + InitPathAndLog(Config.EndpointPath, plugin.Log); - UserEmailUrl = config["user_email_url"].GetString() ?? throw new KeyNotFoundException("Missing required key 'user_email_url' for github configuration"); + //Load secrets + _ = plugin.DeferTask(async () => + { + //Get id/secret + Task<SecretResult?> clientIdTask = plugin.TryGetSecretAsync("github_client_id"); + Task<SecretResult?> secretTask = plugin.TryGetSecretAsync("github_client_secret"); - InitPathAndLog(Config.EndpointPath, plugin.Log); + await Task.WhenAll(secretTask, clientIdTask); + + using SecretResult? secret = await secretTask; + using SecretResult? clientId = await clientIdTask; + + Config.ClientID = clientId?.Result.ToString() ?? throw new KeyNotFoundException("Missing Github client id from config or vault"); + Config.ClientSecret = secret?.Result.ToString() ?? throw new KeyNotFoundException("Missing the Github client secret from config or vault"); + + }, 100); } protected override void StaticClientPoolInitializer(RestClient client) @@ -211,6 +215,5 @@ namespace VNLib.Plugins.Essentials.SocialOauth.Endpoints return accountData; } - } }
\ No newline at end of file |