Skip to content

Instantly share code, notes, and snippets.

View AaronSadlerUK's full-sized avatar

Aaron AaronSadlerUK

View GitHub Profile
@AaronSadlerUK
AaronSadlerUK / IndexHelperComposer.cs
Created August 7, 2021 18:52
How to create a custom index in Umbraco V9
using Examine;
using Microsoft.Extensions.DependencyInjection;
using UmbHost.Core.Components;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Infrastructure.Examine;
namespace UmbHost.Core.Composers
{
public class IndexHelperComposer : IUserComposer
@AaronSadlerUK
AaronSadlerUK / MemberAuthenticationSurfaceController.cs
Last active August 31, 2022 03:05
How to create member login and logout form in Umbraco V9 (RC)
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Common.Models;
@AaronSadlerUK
AaronSadlerUK / bundleconfig.json
Created October 6, 2021 18:40
How to use bundling and minification with Umbraco V9
[
{
"outputFileName": "wwwroot/css/site.min.css",
"inputFiles": [
"wwwroot/lib/bootstrap/dist/css/bootstrap.css",
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/js/site.min.js",
@AaronSadlerUK
AaronSadlerUK / bundleconfig.json
Created October 6, 2021 20:18
How to use bundling and minification with Umbraco V9 (Part 2)
[
{
"outputFileName": "wwwroot/bundles/site.min.css",
"inputFiles": [
"wwwroot/lib/bootstrap/dist/css/bootstrap.css",
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/bundles/site.min.js",
@AaronSadlerUK
AaronSadlerUK / ISyndicationXmlService.cs
Last active October 27, 2021 14:54
How to create an RSS & Atom feed in Umbraco V9
using System.ServiceModel.Syndication;
public interface ISyndicationXmlService
{
Atom10FeedFormatter GenerateAtomXml(string feedTitle, string feedDescription);
Rss20FeedFormatter GenerateRssXml(string feedTitle, string feedDescription);
}
@AaronSadlerUK
AaronSadlerUK / ISiteMapXmlService.cs
Created October 13, 2021 09:55
How to create an Xml Sitemap in Umbraco V9
public interface ISiteMapXmlService
{
public string GenerateXml();
}
@AaronSadlerUK
AaronSadlerUK / HeaderPolicyCollection.cs
Last active December 2, 2021 18:05
Configuring HTTP Security Headers In Umbraco V9
public static HeaderPolicyCollection GetHeaderPolicyCollection(bool isDev)
{
var policy = new HeaderPolicyCollection()
.AddFrameOptionsDeny()
.AddXssProtectionBlock()
.AddContentTypeOptionsNoSniff()
.AddReferrerPolicyStrictOriginWhenCrossOrigin()
.RemoveServerHeader()
.AddCrossOriginOpenerPolicy(builder =>
{
@AaronSadlerUK
AaronSadlerUK / WebPMiddleware.cs
Last active July 5, 2022 14:04
Dynamic WebP Images in Umbraco V10
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
public class WebPMiddleware
{
private readonly RequestDelegate _next;
@AaronSadlerUK
AaronSadlerUK / IValidateYubiKeyOTPService.cs
Last active August 29, 2022 11:23
YubiKey OTP - Umbraco V10
public interface IValidateYubiKeyOTPService
{
Task<bool> ValidateYubiKey(string otp);
}
@AaronSadlerUK
AaronSadlerUK / Command
Created November 20, 2022 14:55
Auto update WMSVC Certificate after Win-Acme runs
.\wacs.exe --installation script --script "Scripts\ImportWMSVC.ps1" --scriptparameters "'{CertThumbprint}'" --certificatestore My