Skip to content

Commit

Permalink
Merge pull request #1013 from Strongminds/hotfix/KITOSUDV-3027-fix-de…
Browse files Browse the repository at this point in the history
…ployment

Hotfix/KITOSUDV-3027 fix deployment
  • Loading branch information
a-naskret authored Dec 15, 2023
2 parents 4ba6ac7 + bbabe82 commit f055b45
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 7 deletions.
9 changes: 8 additions & 1 deletion DeploymentScripts/DeployWebsite.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Function Deploy-Website($packageDirectory, $msDeployUrl, $msDeployUser, $msDeployPassword, $logLevel, $esUrl, $securityKeyString, $smtpFromMail, $smtpNwHost, $resetPwTtl, $mailSuffix, $baseUrl, $kitosEnvName, $buildNumber, $kitosDbConnectionString, $hangfireConnectionString, $defaultUserPassword, $useDefaultUserPassword, $ssoServiceProviderServer, $ssoIDPEndPoints, $ssoServiceProviderId, $ssoCertificateThumbPrint, $stsOrganisationEndpointHost, $robotsFileName, $smtpNetworkPort, $smtpNetworkUsername, $smtpNetworkPassword) {

$msdeploy = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe";

#Base64 encode $kitosContext variable, and add base64: at the beggining
$kitosContext = "base64:" + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($kitosDbConnectionString))

#Base64 encode $hangfireConnectionString variable, and add base64: at the beggining
$hangfireContext = "base64:" + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($hangfireConnectionString))

$fullCommand=$(("`"{0}`" " +
"-verb:sync " +
"-source:package=`"{1}\Presentation.Web.zip`" " +
Expand Down Expand Up @@ -34,7 +41,7 @@ Function Deploy-Website($packageDirectory, $msDeployUrl, $msDeployUser, $msDeplo
"-setParam:name=`"SmtpPort`",value=`"{25}`" " +
"-setParam:name=`"SmtpUserName`",value=`"{26}`" " +
"-setParam:name=`"SmtpPassword`",value=`"{27}`"") `
-f $msdeploy, $packageDirectory, $msDeployUrl, $msDeployUser, $msDeployPassword, $logLevel, $esUrl, $securityKeyString, $smtpFromMail, $smtpNwHost, $resetPwTtl, $baseUrl, $mailSuffix, $kitosEnvName, $buildNumber, $kitosDbConnectionString, $hangfireConnectionString, $defaultUserPassword, $useDefaultUserPassword, $ssoServiceProviderServer, $ssoIDPEndPoints, $ssoServiceProviderId, $ssoCertificateThumbPrint, $stsOrganisationEndpointHost, $robotsFileName, $smtpNetworkPort, $smtpNetworkUsername, $smtpNetworkPassword)
-f $msdeploy, $packageDirectory, $msDeployUrl, $msDeployUser, $msDeployPassword, $logLevel, $esUrl, $securityKeyString, $smtpFromMail, $smtpNwHost, $resetPwTtl, $baseUrl, $mailSuffix, $kitosEnvName, $buildNumber, $kitosContext, $hangfireContext, $defaultUserPassword, $useDefaultUserPassword, $ssoServiceProviderServer, $ssoIDPEndPoints, $ssoServiceProviderId, $ssoCertificateThumbPrint, $stsOrganisationEndpointHost, $robotsFileName, $smtpNetworkPort, $smtpNetworkUsername, $smtpNetworkPassword)

& cmd.exe /C $fullCommand

Expand Down
2 changes: 2 additions & 0 deletions Infrastructure.DataAccess/Infrastructure.DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
Expand Down Expand Up @@ -1054,6 +1055,7 @@
<Compile Include="Services\PocoTypeFromProxyResolver.cs" />
<Compile Include="Services\WithinAmbienTransaction.cs" />
<Compile Include="Services\TransactionManager.cs" />
<Compile Include="Tools\ConnectionStringTools.cs" />
<Compile Include="Tools\SqlMigrationScriptRepository.cs" />
<Compile Include="TypeConfigurationExtensions.cs" />
<Compile Include="TypeMapping.cs" />
Expand Down
5 changes: 3 additions & 2 deletions Infrastructure.DataAccess/KitosContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
using Core.DomainModel.Notification;
using Core.DomainModel.Tracking;
using Core.DomainModel.UIConfiguration;
using Infrastructure.DataAccess.Tools;

namespace Infrastructure.DataAccess
{
public class KitosContext : DbContext
{
public KitosContext() : this("KitosContext") { }

public KitosContext() : this(ConnectionStringTools.GetConnectionString("KitosContext")) { }
public KitosContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
Expand Down
19 changes: 19 additions & 0 deletions Infrastructure.DataAccess/Tools/ConnectionStringTools.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace Infrastructure.DataAccess.Tools
{
public class ConnectionStringTools
{
public static string GetConnectionString(string dbName)
{
var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[dbName]?.ConnectionString ?? dbName;
if (!connectionString.StartsWith("base64:"))
return connectionString;

var base64EncodedString = connectionString.Substring("base64:".Length);
var base64EncodedBytes = Convert.FromBase64String(base64EncodedString);
connectionString = System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
return connectionString;
}
}
}
1 change: 1 addition & 0 deletions Presentation.Web/LoginHandler.ashx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%@ WebHandler Language="C#" CodeBehind="LoginHandler.ashx.cs" Class="Presentation.Web.LoginHandler" %>
17 changes: 17 additions & 0 deletions Presentation.Web/LoginHandler.ashx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Web;

namespace Presentation.Web
{
/// <summary>
/// LoginHandler redirects to the Login.ashx page with the forceAuthn parameter set to true.
/// </summary>
public class LoginHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.Redirect("Login.ashx?forceAuthn=true");
}

public bool IsReusable => false;
}
}
4 changes: 4 additions & 0 deletions Presentation.Web/Presentation.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@
<Compile Include="Infrastructure\Attributes\V2StyleJsonResponseSerializationAttribute.cs" />
<Compile Include="Infrastructure\Config\V2JsonSerializationConfig.cs" />
<Compile Include="Controllers\API\V2\Internal\Notifications\Mapping\NotificationTypeMappingExtensions.cs" />
<Compile Include="LoginHandler.ashx.cs">
<DependentUpon>LoginHandler.ashx</DependentUpon>
</Compile>
<Compile Include="Models\API\V1\NamedEntityWithUuidDTO.cs" />
<Compile Include="Models\API\V1\UserCredentialsDTO.cs" />
<Compile Include="Models\API\V2\Internal\Request\Notifications\BaseNotificationPropertiesWriteRequestDTO.cs" />
Expand Down Expand Up @@ -1745,6 +1748,7 @@
<Content Include="Content\notify\notify.less" />
<Content Include="app\components\local-config\local-config-option-edit.modal.view.html" />
<Content Include="Metadata.ashx" />
<Content Include="LoginHandler.ashx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
5 changes: 2 additions & 3 deletions Presentation.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
using Presentation.Web.Ninject;
using Presentation.Web.Infrastructure.Filters;
using Presentation.Web.Infrastructure;
using System.Net;
using System.Net.Security;
using Infrastructure.DataAccess.Tools;

[assembly: OwinStartup(typeof(Presentation.Web.Startup))]
namespace Presentation.Web
Expand Down Expand Up @@ -55,7 +54,7 @@ private static void InitializeHangfire(IAppBuilder app)
var standardKernel = new KernelBuilder().ForHangFire().Build();

GlobalConfiguration.Configuration.UseNinjectActivator(standardKernel);
GlobalConfiguration.Configuration.UseSqlServerStorage("kitos_HangfireDB");
GlobalConfiguration.Configuration.UseSqlServerStorage(ConnectionStringTools.GetConnectionString("kitos_HangfireDB"));
GlobalJobFilters.Filters.Add(new AdvisSendFailureFilter(standardKernel));
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = KitosConstants.MaxHangfireRetries });

Expand Down
2 changes: 1 addition & 1 deletion Presentation.Web/app/components/home/home.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h3 class="panel-title">Single Sign-On (SSO)</h3>
<div class="panel-body">
<div class="text-left col-xs-10">
<div>
<a href="Login.ashx?forceAuthn=true" class="btn btn-default btn-sm">Log ind via fælleskommunal adgangsstyring</a>
<a href="LoginHandler.ashx" class="btn btn-default btn-sm">Log ind via fælleskommunal adgangsstyring</a>
</div>
</div>
</div>
Expand Down

0 comments on commit f055b45

Please sign in to comment.