Skip to content

Instantly share code, notes, and snippets.

View magohl's full-sized avatar

Magnus Ohlsson magohl

View GitHub Profile
@magohl
magohl / SoapUI - Mock response script Random content.txt
Created October 21, 2022 07:28
SoapUI - Mock response script Random content
script:
def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
def someInput = holder["//*[local-name()='SomeInput']"]
def random = Math.random()
requestContext.someInput = someInput
requestContext.randomText = random.toString()
response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://kramerica-industries.lan/webservices/dummyservice/1.0" xmlns:res="http://oresundsbron.com/types/result">
<soapenv:Header/>
@magohl
magohl / gist:a2fa5c5c141ef76d660abb9a2f4f2ad4
Created August 15, 2022 15:47
Fetch OAuth token using Managed Identity from Azure App Service
$ProgressPreference = "SilentlyContinue"
$tokenResponse = Invoke-WebRequest -UseBasicParsing -Headers @{"X-IDENTITY-HEADER"=$env:IDENTITY_HEADER} -Uri "$($env:IDENTITY_ENDPOINT)?resource=https://storage.azure.com/&api-version=2019-08-01"
$tokenResponse.RawContent
$request = @{
Uri = 'http://localhost/SuperImportant/service.svc'
Method = 'POST'
Body = '{
"name": "testing",
"prio": "24"}'
ContentType = 'application/json'
}
while (1)
curl -k -v -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"result\":\"test\"}" https://localhost:5001/test
@magohl
magohl / gist:98dab37dfca8059517bfd675eb735660
Last active October 11, 2022 14:42
powershell - generate certificate
// example using an ip as SAN subject alternate name
New-SelfSignedCertificate -NotBefore (Get-Date) -NotAfter (Get-Date).AddYears(1) -Subject "idp" -KeyAlgorithm "RSA" -KeyLength 2048 -HashAlgorithm "SHA256" -CertStoreLocation "Cert:\CurrentUser\My" -KeyUsage KeyEncipherment -FriendlyName "192.168.43.1 development certificate v2" -TextExtension @("2.5.29.19={critical}{text}","2.5.29.37={critical}{text}1.3.6.1.5.5.7.3.1","2.5.29.17={critical}{text}DNS=192.168.43.1&IPAddress=192.168.43.1")
// Client authentication only. 10years
New-SelfSignedCertificate -Type Custom -Subject "CN=kramerica-xyz-dev-spn,O=Kramerica SelfSigned DEV" -KeyUsage DigitalSignature -KeyLength 4096 -KeyAlgorithm RSA -HashAlgorithm "SHA512" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2") -NotAfter (Get-Date).AddYears(10) -CertStoreLocation "Cert:\LocalMachine\My"
@magohl
magohl / kubernetes.stuff.txt
Last active April 5, 2022 20:57
Kubernetes stuff
minimal create
kubectl run test --rm -it --image=alpine --generator=run-pod/v1
kubectl proxy
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Get token
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | awk '/^deployment-controller-token-/{print $1}') | awk '$1=="token:"{print $2}'
Install helm w RBAC
kubectl -n kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account=tiller
Update context
minikube update-context
Install Traefik using Helm (https://8gwifi.org/docs/kube-traefik.jsp)
helm install stable/traefik --name traefik --set dashboard.enabled=true,serviceType=NodePort,dashboard.domain=dashboard.traefik,rbac.enabled=true --namespace kube-system
@magohl
magohl / Add OIDC manually without metadata
Created June 4, 2019 09:44
AspNet Core - Add OIDC manually without metadata
Here we are using demo.identotyserver.io.
Its not enough to add JsonWebKeySet. You have to add SigningKeys also!!
services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultSignInScheme = "Cookies";
options.DefaultSignOutScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
Forgot the WP password and no smtp setup?
docker exec into the mysql container
USE wordpress
UPDATE wp_users SET user_pass = MD5("my-new-password") WHERE wp_users.user_login = "my-admin-user";