Skip to content

Commit

Permalink
Merge branch 'Kentico:main' into fix/add-request-localization-middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
liamgold authored Feb 10, 2024
2 parents e60dcb8 + bfb1e56 commit aaee0f5
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 106 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
name: "CI: Build and Test"

on:
# Disabled for now since the deploy.yml also does a build and almost all updates come through PRs
# We don't need to duplicate the build once a PR merges
# push:
# branches: [main]
# paths:
# - "**.cs"
# - "**.csproj"
# - "**.props"
# - "**.targets"
# - "**.sln"
# - "**.ps1"
pull_request:
branches: [main]
paths:
Expand Down Expand Up @@ -94,7 +83,7 @@ jobs:
-DestinationPath "./database"
- name: Install a SQL Server suite of tools (SQLEngine, SQLPackage)
uses: potatoqualitee/[email protected]
uses: potatoqualitee/mssqlsuite@9a0136e208df60b8ecb62909f076bc34854fa55a # set as a commit hash for security - v1.7
with:
install: sqlpackage, sqlengine
sa-password: Pass@12345
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public CaptchaValidator(IOptions<ReCaptchaSettings> options, IHttpClientFactory

public async Task<CaptchaValidationResult> ValidateCaptcha(ICaptchaClientResponse clientResponse)
{
if (settings.IsValidationDisabled)
{
return new() { IsSuccess = true };
}

string secret = settings.SecretKey;
var client = httpClientFactory.CreateClient();
string requestURL = string.Format(
Expand All @@ -33,20 +38,20 @@ public async Task<CaptchaValidationResult> ValidateCaptcha(ICaptchaClientRespons

if (response is null)
{
return new CaptchaValidationResult { IsSuccess = false, ErrorMessage = "Could not validate captcha" };
return new() { IsSuccess = false, ErrorMessage = "Could not validate captcha" };
}

if (response.Score < settings.ScoreThredhold)
{
return new CaptchaValidationResult { IsSuccess = false, ErrorMessage = "Invalid captcha score" };
return new() { IsSuccess = false, ErrorMessage = "Invalid captcha score" };
}

if (!response.IsSuccess)
{
return new CaptchaValidationResult { IsSuccess = false, ErrorMessage = response.ErrorMessages.FirstOrDefault() ?? "Captcha failed" };
return new() { IsSuccess = false, ErrorMessage = response.ErrorMessages.FirstOrDefault() ?? "Captcha failed" };
}

return new CaptchaValidationResult { IsSuccess = true };
return new() { IsSuccess = true };
}

public class CaptchaResponse
Expand Down Expand Up @@ -74,6 +79,10 @@ public class CaptchaValidationResult

public class ReCaptchaSettings
{
/// <summary>
/// Used to disable server-side captcha validation in specific scenarios (ex: CI)
/// </summary>
public bool IsValidationDisabled { get; set; }
public string SiteKey { get; set; } = "";
public string SecretKey { get; set; } = "";
public double ScoreThredhold { get; set; }
Expand Down
39 changes: 39 additions & 0 deletions src/Kentico.Community.Portal.Web/appsettings.CI.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"ConnectionStrings": {
"CMSConnectionString": "Data Source=localhost;Initial Catalog=Kentico.Community;User Id=sa;Password=Pass@12345;Persist Security Info=False;Connect Timeout=10;Encrypt=False;Current Language=English;TrustServerCertificate=True;"
},

"CMSHashStringSalt": "hash-string-salt",

"CMSAdminSettings": {
"Authentication": {
"Identity": {
"AzureAD": {
"Domain": "ci-domain.onmicrosoft.com",
"TenantId": "ci-tenant-id",
"ClientId": "ci-client-id",
"Instance": "https://login.microsoftonline.com/",
"CallbackPath": "/admin-oidc"
}
}
}
},

"CMSSendGrid": {
"ApiKey": "<placeholder>"
},

"Kentico.Xperience.Lucene.Custom": {
"WebCrawlerBaseUrl": "https://localhost:45039"
},

"ReCaptcha": {
"SiteKey": "6LfJIt0ZAAAAADy4LwyLOjqH0Fynf85tX5o9HF-5",
"SecretKey": "test-secret",
"ScoreThreshold": 0,
"IsValidationDisabled": true
},

"Cache": {
"Query": {
"IsEnabled": true,
"IsSlidingExpiration": false,
"CacheItemDuration": 1
}
}
}
36 changes: 23 additions & 13 deletions src/Kentico.Community.Portal.Web/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Warning",
"Vite.AspNetCore.Services.ViteManifest": "Warning"
"System.Net.Http.HttpClient": "Warning"
},
"KenticoEventLog": {
"LogLevel": {
Expand All @@ -14,31 +13,42 @@
}
}
},
"AllowedHosts": "*",

"MicrosoftDynamics": {
"Url": "<url>",
"SupportCasesDirectory": "SupportCases",
"ProcessedCasesDirectory": "Processed"
},
"CMSHashStringSalt": "hash-string-salt",

"GoogleTagManager": {
"Code": "GTM-KXPK66G"
"CMSAdminSettings": {
"Authentication": {
"Identity": {
"AzureAD": {
"Domain": "ci-domain.onmicrosoft.com",
"TenantId": "ci-tenant-id",
"ClientId": "ci-client-id",
"Instance": "https://login.microsoftonline.com/",
"CallbackPath": "/admin-oidc"
}
}
}
},

"xperience.lucene": {
"Kentico.Xperience.Lucene.Custom": {
"WebCrawlerBaseUrl": "https://localhost:45039/"
},

"DefaultSenderAddress": "no-reply@localhost:45039",

"SmtpOptions": {
"Server": {
"Host": "localhost",
"Port": 1025
}
},

"Cache": {
"Query": {
"IsEnabled": true,
"IsSlidingExpiration": false,
"CacheItemDuration": 1
}
},

"Vite": {
"Base": "dist/",
"Server": {
Expand Down
54 changes: 0 additions & 54 deletions src/Kentico.Community.Portal.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,6 @@
},
"AllowedHosts": "*",

"ConnectionStrings": {
"CMSConnectionString": ""
},

"CMSHashStringSalt": "<Generate a GUID>",

"xperience.lucene": {
"WebCrawlerBaseUrl": "https://community.kentico.com/"
},

"MicrosoftDynamics": {
"Url": "<https://url.com>",
"SupportCasesDirectory": "SupportCases",
"ProcessedCasesDirectory": "Processed"
},

"GoogleTagManager": {
"Code": "<code>"
},

"ReCaptcha": {
"SiteKey": "test-key",
"SecretKey": "test-secret",
"ScoreThreshold": 0.5
},

"CMSSendGrid": {
"ApiKey": "<placeholder>"
},

"Cache": {
"Query": {
"IsEnabled": true,
"IsSlidingExpiration": false,
"CacheItemDuration": 5
}
},

"DefaultSenderAddress": "[email protected]",

"CMSAdminSettings": {
"Authentication": {
"Identity": {
"AzureAD": {
"Domain": "<your domain>",
"TenantId": "<tenant-id>",
"ClientId": "<client-id>",
"Instance": "https://login.microsoftonline.com/",
"CallbackPath": "/admin-oidc"
}
}
}
},

"Vite": {
"Base": "dist/",
"Manifest": "manifest.json"
Expand Down
6 changes: 0 additions & 6 deletions src/Kentico.Community.Portal.Web/appsettings.qa.json

This file was deleted.

17 changes: 0 additions & 17 deletions src/Kentico.Community.Portal.Web/appsettings.uat.json

This file was deleted.

0 comments on commit aaee0f5

Please sign in to comment.