Skip to content

Instantly share code, notes, and snippets.

View dsolovay's full-sized avatar

Dan Solovay dsolovay

View GitHub Profile
@dsolovay
dsolovay / Get_media_upload_url.js
Created September 28, 2023 00:22
Picsum Demo
import axios from "axios"
// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
props: {
data: {type: "data_store"}
},
async run({ steps, $ }) {
// Return data to use it in future steps
var url = process.env.NGROK_SITECORE_CM_URL;
if (url.substr(-1) != '/') url += '/';
@dsolovay
dsolovay / GetToken.ps1
Last active October 1, 2023 23:03
Enable Token Requests for Sitecore ID server
function Get-Token {
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/x-www-form-urlencoded")
$headers.Add("Accept", "application/json")
$body = "password=b&grant_type=password&username=sitecore%5Cadmin&client_id=postman-api&scope=openid%20sitecore.profile%20sitecore.profile.api"
$response = Invoke-RestMethod 'https://xm1id.localhost/connect/token' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
@dsolovay
dsolovay / Sitecore.IdentityServer.Host.xml
Created January 4, 2023 03:48
Get GraphQL Access token for Sitecore 10.3
<!-- NOTE: THIS IS A FRAGMENT. INCLUDE THIS IN Sitecore.IdentityServer.Host.xml, in node /Settings/Sitecore/IdentityServer/Clients -->
<!-- Postman configuration documented here: https://doc.sitecore.com/xp/en/developers/92/sitecore-experience-commerce/bearer-token-authentication.html -->
<PostmanClient>
<ClientId>postman-api</ClientId>
<ClientName>Postman API</ClientName>
<AccessTokenType>0</AccessTokenType>
<AllowOfflineAccess>true</AllowOfflineAccess>
<AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
<AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
@dsolovay
dsolovay / Get-SitecoreReleaseNotes
Last active August 15, 2022 14:07
Download Sitecore release notes to hash table
function Get-SitecoreReleaseNotes()
{
$links = (invoke-webrequest https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform.aspx).Links
$versions = $links |? {$_.innerText -like 'Sitecore Experience Platform*' -and $_.InnerText -notlike '*and below*'} # https://www.howtogeek.com/124736/stupid-geek-tricks-extract-links-off-any-webpage-using-powershell/
$versionlinks = @{}
$versions |% { $versionLinks.Add($_.innerHtml, $_.href)}
$releaseNotes = @{}
$versionLinks.Keys |%{
$releaseNotesUrl = "https://dev.sitecore.net" + ($versionLinks[$_]).Trim(".aspx") + "/Release%20Notes"
Write-Verbose $releaseNotesUrl
<%@ Page %>
<%@ Import namespace="Sitecore.ContentSearch" %>
<%@ Import namespace="Sitecore.ContentSearch.SearchTypes" %>
<html>
<body>
<form runat=server>
<!-- <asp:textbox runat=server id=tb1 /> -->
<asp:button runat=server text=Click onclick=DoSearch />
<script runat=server>
@dsolovay
dsolovay / CustomCampaignCreator.config
Created December 21, 2021 22:23
How to modify Campaign Creator to not embed IDs in campaign names
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:env="http://www.sitecore.net/xmlconfig/env/">
<sitecore >
<services>
<configurator type="CustomCampaignRepository.ServicesConfigurator, CustomCampaignRepository" />
</services>
</sitecore>
</configuration>
@dsolovay
dsolovay / ConfigureSitecore.cs
Last active December 10, 2021 22:09
Code samples for Part 2 of Sustainsys.SAML2 Sitecore Identity plugin
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
@dsolovay
dsolovay / CacheFixture.cs
Last active October 7, 2021 04:13
Illustrates zero-friction TDD ideas, use of Sitecore base classes, and tuple deconstructors
using NSubstitute;
using Sitecore.Abstractions;
namespace UnitTestingDemo
{
internal static class CacheFixture
{
public static (CustomCacheFactory, BaseCacheManager, BaseSettings) CreateCache()
{
BaseCacheManager cacheManager = Substitute.For<BaseCacheManager>();
@dsolovay
dsolovay / parameters.xml
Created September 19, 2021 03:14
Simple WebDeploy parameter configuration
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<parameter name="Application Ribbon Home Label"
description="Label that appears in ribbon"
defaultvalue="Application name" >
<parameterEntry kind="TextFile" scope="_Layout.cshtml" match="Application name" />
</parameter>
</parameters>
@dsolovay
dsolovay / ConfigureSitecore.cs
Last active December 8, 2021 06:01
Sitecore Identity to Sustainsys Plugin
using IdentityServer4;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Sustainsys.Saml2;
using Sustainsys.Saml2.Configuration;
using Sustainsys.Saml2.Metadata;
using Sustainsys.Saml2.WebSso;
namespace SitecoreIdentitySamlDemo
{