Skip to content

Commit 48e75ff

Browse files
Managed DNS: use mgmt hub api automatically if set
1 parent 9c7a0b1 commit 48e75ff

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/Certify.Providers/DNS/CertifyManaged/DnsProviderCertifyManaged.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Certify.Models.Plugins;
99
using Certify.Models.Providers;
1010
using Certify.Plugins;
11+
using Certify.SharedUtils;
1112
using Newtonsoft.Json;
1213

1314
/// <summary>
@@ -31,9 +32,9 @@ public static ChallengeProviderDefinition Definition
3132
HelpUrl = "https://docs.certifytheweb.com/",
3233
PropagationDelaySeconds = 60,
3334
ProviderParameters = new List<ProviderParameter>{
34-
new ProviderParameter{ Key="api",Name="Management Hub API Url", IsRequired=true, IsCredential=false, IsPassword=false, Value="https://localhost:44361/", Description="Base URL for a Certify Management Hub API" },
35-
new ProviderParameter{ Key="authkey",Name="Auth Key", IsRequired=true, IsCredential=true, IsPassword=false, Description="API Auth Key" },
36-
new ProviderParameter{ Key="authsecret",Name="Auth Secret", IsRequired=true, IsCredential=true, IsPassword=true, Description="API Auth Secret" }
35+
new ProviderParameter{ Key="api",Name="Management Hub API Url", IsRequired=false, IsCredential=false, IsPassword=false, Value="https://localhost:44361/", Description="(leave blank to use current management hub API)" },
36+
new ProviderParameter{ Key="authkey",Name="Client ID", IsRequired=true, IsCredential=true, IsPassword=false, Description="API Auth Key" },
37+
new ProviderParameter{ Key="authsecret",Name="Client Secret", IsRequired=true, IsCredential=true, IsPassword=true, Description="API Auth Secret" }
3738
},
3839
IsTestModeSupported = true,
3940
ChallengeType = SupportedChallengeTypes.CHALLENGE_TYPE_DNS,
@@ -227,8 +228,26 @@ public async Task<bool> InitProvider(Dictionary<string, string> credentials, Dic
227228
}
228229
else
229230
{
230-
_log.Error("Certify Managed Challenge DNS Provider could not be created: managed challenge API URL not set.");
231-
return false;
231+
var svcConfig = ServiceConfigManager.GetAppServiceConfig();
232+
var mgmtHubAPI = svcConfig?.ManagementServerHubAPI;
233+
234+
if (mgmtHubAPI != null)
235+
{
236+
// if we have a management hub API URL, use that
237+
_apiBaseUri = new System.Uri(mgmtHubAPI);
238+
239+
if (!_apiBaseUri.ToString().EndsWith("/"))
240+
{
241+
_apiBaseUri = new Uri($"{_apiBaseUri}/");
242+
}
243+
244+
_client.BaseAddress = _apiBaseUri;
245+
}
246+
else
247+
{
248+
_log.Error("Certify Managed Challenge DNS Provider could not be created: managed challenge API URL not set.");
249+
return false;
250+
}
232251
}
233252

234253
return await Task.FromResult(true);

src/Certify.Providers/DNS/CertifyManaged/Plugin.DNS.CertifyManaged.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup>
1010
<ProjectReference Include="..\..\..\Certify.Models\Certify.Models.csproj" />
11+
<ProjectReference Include="..\..\..\Certify.Shared\Certify.Shared.Core.csproj" />
1112

1213
</ItemGroup>
1314

0 commit comments

Comments
 (0)