Skip to content

Instantly share code, notes, and snippets.

View herskinduk's full-sized avatar

Kern Herskind Nightingale herskinduk

View GitHub Profile
@herskinduk
herskinduk / ConfigureActionFilters.cs
Created February 24, 2017 00:32
ItemService database restrinction
using Headless.ItemService;
using Sitecore.Pipelines;
using System.Web.Http;
namespace Headless
{
public class ConfigureActionFilters
{
private HttpConfiguration configuration;
private RestrictDatabaseActionFilter actionFilter;
using Sitecore.Mvc.Helpers;
using Sitecore.Mvc.Pipelines;
using Sitecore.Mvc.Pipelines.Response.RenderRendering;
using Sitecore.Mvc.Presentation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
// Use the async execute
var asyncController = controller as IAsyncController;
Task.Factory.FromAsync(asyncController.BeginExecute, asyncController.EndExecute, PageContext.Current.RequestContext, null).Wait();
// The old way (sync)
//(controller as IController).Execute(PageContext.Current.RequestContext);
app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(
new CookieAuthenticationOptions
{
AuthenticationType =
WsFederationAuthenticationDefaults.AuthenticationType
});
app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
{
MetadataAddress = ...,
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
//use OpenId
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = ...,
Authority = ...,
@herskinduk
herskinduk / ItemServiceConsoler.cs
Last active August 29, 2015 14:19
SSC Item Service server-to-server example
using System;
using System.Net;
using System.Net.Http;
using System.Text;
namespace ItemServiceConsoler
{
class Program
{
static void Main(string[] args)
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<indexConfigurations>
<!-- Un-comment out the config for Lucene or SOLR for your project -->
<defaultLuceneIndexConfiguration>
<indexDocumentPropertyMapper>
@herskinduk
herskinduk / gist:c718a70852e7bc3dcb25
Created October 30, 2014 21:24
msbuild target for generating T4 assembly directives based on project references
<Target Name="Write_AssemblyRefs_TT" BeforeTargets="TransformOnBuild">
<!-- A message for all to enjoy! -->
<WriteLinesToFile File="@(MyTextFile)"
Lines="&lt;# /* AUTOGENERATED BY MSBUILD and Kern Herskind Nightingale */ #&gt;"
Overwrite="true"
Encoding="Unicode" />
<!-- Output all assembly references with a HintPath -->
<WriteLinesToFile File="@(MyTextFile)"
Lines="&lt;#@ assembly name=&quot;$(ProjectDir)%(Reference.HintPath)&quot; #&gt;"
Overwrite="false"
@herskinduk
herskinduk / LuceneDocumentTypeMapper.cs
Created October 24, 2014 18:30
Fix for fortis lucene content search
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Fortis;
using Fortis.Model;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Linq.Methods;
using Sitecore.ContentSearch.Security;
using Sitecore.Data;
@herskinduk
herskinduk / ArticleViewRendering.cshtml
Last active April 29, 2016 08:34
Sitecore MVC inside-out layout
@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc
@model RenderingModel
@{
Layout = null;
Sitecore.Context.Items["twitter:title"] = Model.Item["title"]
Sitecore.Context.Items["twitter:description"] = Model.Item["description"]
}
<h1>@Html.Sitecore().Field("title")</h1>
@Html.Sitecore().Field("text")