Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra setting (TipSlotName) #395

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LetsEncrypt-SiteExtension/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public async Task<ActionResult> Index(AuthenticationModel model)
{ AppSettingsAuthConfig.subscriptionIdKey, model.SubscriptionId.ToString() },
{ AppSettingsAuthConfig.tenantKey, model.Tenant },
{ AppSettingsAuthConfig.resourceGroupNameKey, model.ResourceGroupName },
{ AppSettingsAuthConfig.tipSlotNameKey, model.TipSlotName},
{ AppSettingsAuthConfig.siteSlotNameKey, model.SiteSlotName},
{ AppSettingsAuthConfig.servicePlanResourceGroupNameKey, model.ServicePlanResourceGroupName },
{ AppSettingsAuthConfig.useIPBasedSSL, model.UseIPBasedSSL.ToString().ToLowerInvariant() }
Expand Down Expand Up @@ -121,6 +122,7 @@ public async Task<ActionResult> Index(AuthenticationModel model)
!ValidateModelVsAppSettings("ResourceGroupName", appSetting.ResourceGroupName, model.ResourceGroupName) ||
!ValidateModelVsAppSettings("SubScriptionId", appSetting.SubscriptionId.ToString(), model.SubscriptionId.ToString()) ||
!ValidateModelVsAppSettings("Tenant", appSetting.Tenant, model.Tenant) ||
!ValidateModelVsAppSettings("TipSlotName", appSetting.TipSlotName, model.TipSlotName) ||
!ValidateModelVsAppSettings("SiteSlotName", appSetting.SiteSlotName, model.SiteSlotName) ||
!ValidateModelVsAppSettings("ServicePlanResourceGroupName", appSetting.ServicePlanResourceGroupName, model.ServicePlanResourceGroupName) ||
!ValidateModelVsAppSettings("UseIPBasedSSL", appSetting.UseIPBasedSSL.ToString().ToLowerInvariant(), model.UseIPBasedSSL.ToString().ToLowerInvariant()))
Expand Down
5 changes: 5 additions & 0 deletions LetsEncrypt-SiteExtension/Models/AuthenticationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public string WebAppName
{
get; set;
}
public string TipSlotName
{
get; set;
}
public string SiteSlotName
{
get; set;
Expand Down Expand Up @@ -122,6 +126,7 @@ public static explicit operator AuthenticationModel(AppSettingsAuthConfig config
AzureWebSitesDefaultDomainName = config.AzureWebSitesDefaultDomainName,
ManagementEndpoint = config.ManagementEndpoint,
TokenAudience = config.TokenAudience,
TipSlotName = config.TipSlotName,
SiteSlotName = config.SiteSlotName,
WebRootPath = config.WebRootPath,
RunFromPackage = config.RunFromPackage,
Expand Down
11 changes: 11 additions & 0 deletions LetsEncrypt-SiteExtension/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<td>@LetsEncrypt.Azure.Core.Models.AppSettingsAuthConfig.useIPBasedSSL</td>
<td>Check this if you want the certificate to be bound to the WebApps' IP address instead of using SNI. With IP based SSL additional costs might be charged.</td>
</tr>
<tr>
<td>@LetsEncrypt.Azure.Core.Models.AppSettingsAuthConfig.tipSlotNameKey</td>
<td>(Optional) Use this setting if you are using Testing-In-Production and you are currently serving from a deployment slot. The value should be the name of the slot (and the extension should be installed in <b>PRODUCTION</b> kudu portal)</td>
</tr>
<tr>
<td>@LetsEncrypt.Azure.Core.Models.AppSettingsAuthConfig.siteSlotNameKey</td>
<td>(Optional) Use this setting if you want to use the extension to setup SSL certificate for deployment slots, the value should be the name of the slot (and the extension should be installed in that slots kudu portal)</td>
Expand Down Expand Up @@ -191,6 +195,13 @@
@Html.ValidationMessageFor(model => model.WebAppName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.TipSlotName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TipSlotName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TipSlotName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SiteSlotName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
Expand Down
9 changes: 9 additions & 0 deletions LetsEncrypt.SiteExtension.Core/AppSettingsAuthConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class AppSettingsAuthConfig : IAzureWebAppEnvironment, IAcmeConfig
public const string useIPBasedSSL = "letsencrypt:UseIPBasedSSL";
public const string emailKey = "letsencrypt:Email";
public const string acmeBaseUriKey = "letsencrypt:AcmeBaseUri";
public const string tipSlotNameKey = "letsencrypt:TipSlot";
public const string siteSlotNameKey = "letsencrypt:SiteSlot";
public const string webAppNameKey = "WEBSITE_SITE_NAME";
public const string webRootPath = "letsencrypt:WebRootPath";
Expand Down Expand Up @@ -137,6 +138,14 @@ public string WebRootPath
}
}

public string TipSlotName
{
get
{
return ConfigurationManager.AppSettings[tipSlotNameKey];
}
}

public string SiteSlotName
{
get
Expand Down
12 changes: 11 additions & 1 deletion LetsEncrypt.SiteExtension.Core/IAzureEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public interface IAzureWebAppEnvironment : IAzureEnvironment

string ServicePlanResourceGroupName { get; }

string TipSlotName { get; }

string SiteSlotName { get; }

string AzureWebSitesDefaultDomainName { get; }
Expand Down Expand Up @@ -179,7 +181,15 @@ public string ServicePlanResourceGroupName
_servicePlanResourceGroupName = value;
}
}


/// <summary>
/// The site slot where the challenge file is installed. Only required if multiple slots are used with testing-in-Production.
/// </summary>
public string TipSlotName
{
get; set;
}

/// <summary>
/// The site slot to install the certificate on. Only required if multiple slots is used.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions LetsEncrypt.SiteExtension.Core/KuduHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public static class KuduHelper
{
public static KuduRestClient GetKuduClient(this WebSiteManagementClient client, IAzureWebAppEnvironment settings)
{
var user = client.WebApps.GetPublsihingCredentialSiteOrSlot(settings.ResourceGroupName, settings.WebAppName, settings.SiteSlotName);
var site = client.WebApps.GetSiteOrSlot(settings.ResourceGroupName, settings.WebAppName, settings.SiteSlotName);
var user = client.WebApps.GetPublsihingCredentialSiteOrSlot(settings.ResourceGroupName, settings.WebAppName, settings.TipSlotName);
var site = client.WebApps.GetSiteOrSlot(settings.ResourceGroupName, settings.WebAppName, settings.TipSlotName);
var defaultHostName = site.DefaultHostName;

return new KuduRestClient(MakeScmUri(defaultHostName,settings), user.PublishingUserName, user.PublishingPassword);
Expand Down