Skip to content

Instantly share code, notes, and snippets.

@Anakin-Hao
Anakin-Hao / gist:ece52e5d286553aaedde8b934777ff49
Created December 3, 2018 22:13
Keycloak spi truststore config
<spi name="x509cert-lookup">
<default-provider>apache</default-provider>
<provider name="apache" enabled="true">
<properties>
<property name="sslClientCert" value="ssl-client-cert"/>
<property name="sslCertChainPrefix" value="USELESS"/>
<property name="certificateChainLength" value="2"/>
</properties>
</provider>
</spi>
@Anakin-Hao
Anakin-Hao / gist:74a4cded5c46ef101c86a2c2605f80da
Last active December 6, 2018 00:57
Change line ending for entire repo
git rm -rf --cached .
git reset --hard HEAD
https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows
@Anakin-Hao
Anakin-Hao / gist:66401c7eaaa6eafb3fc8ad803a099597
Created December 11, 2018 00:55
xmlstarlet to added apache mssl spi in keycloak xml
# set alias xl='xmlstarlet'
xl ed -L -u '//spi[@name="x509cert-lookup"]/default-provider' -v "apache" test.xml
xl ed -L -u '//spi[@name="x509cert-lookup"]/provider[@name="default"]/@name' -v "apache" test.xml
xl ed -L -s '//spi[@name="x509cert-lookup"]/provider[@name="apache"]' -t elem -n "properties" test.xml
xl ed -L -s '//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties' -t elem -n "property" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "name" -v "sslClientCert" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "value" -v "ssl-client-cert" test.xml
xl ed -L -s '//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties' -t elem -n "property" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "name" -v "sslCertChainPrefix" test.xml
xl ed -L -i '(//spi[@name="x509c
@Anakin-Hao
Anakin-Hao / gist:a341f923c0dd803ee7ada2d65167296e
Last active January 7, 2019 01:49
Regex match url /path
(?:\/\/[^\/]+\/)([^\/]+)(?:\/*.*)
https://www.ruby-forum.com/tasdas_asd/validate-client-certificate-sdn-fields-cn-ou-o-etc-at-nginx/233221
$1 return tasdas_asd
Or (?:\/)([^\/]+)(?:\/*.*)
/tasdas_asd/validate-client-certificate-sdn-fields-cn-ou-o-etc-at-nginx/233221
@Anakin-Hao
Anakin-Hao / gist:eb09f9ea2a028a4a2e5c140bc81f8c71
Last active January 8, 2019 02:19
NGINX Extract DN from pem cert
map $ssl_client_s_dn $ssl_client_s_dn_cn {
default "";
~CN=(?<CN>[^\/,]+) $CN;
}
map $ssl_client_s_dn $ssl_client_s_dn_o {
default "";
~O=(?<O>[^\/,]+) $O;
}
BEGIN;
ALTER TABLE albi_puff drop constraint albi_puff_realm_id_fkey;
ALTER TABLE albi_puff add constraint albi_puff_realm_id_fkey
FOREIGN KEY (realm_id)
REFERENCES realm(id)
ON DELETE CASCADE;
COMMIT;
@Anakin-Hao
Anakin-Hao / gist:4a716d1643a9f29b7bb6eaa4f82f883a
Created March 25, 2019 01:41
Build all albi containers in a fodler and push
Get-ChildItem .\containers\api\ -Filter albi_*_rest | Foreach-Object {
$name = $_.BaseName
ECHO $name
$short = $name.replace("albi_", "")
$tag = "$short" + ":latest"
ECHO $short
docker build -t 440617634381.dkr.ecr.ap-southeast-2.amazonaws.com/albi/$tag .\\containers\\api\\ -f .\\containers\\api\\$name\\Dockerfile --no-cache
docker push 440617634381.dkr.ecr.ap-southeast-2.amazonaws.com/albi/$tag
kubectl delete pods -l app=$short}
import requests
from requests.auth import HTTPBasicAuth
import time
headers = {'Content-Type': 'application/json', 'performAsync': 'True', 'timeToLiveSeconds': '99999999999'}
body = {'test':123}
auth=HTTPBasicAuth('test', 'changeme')
baseurl = "http://infinispan-server-http/rest"
@Anakin-Hao
Anakin-Hao / infinispan_test.py
Last active May 9, 2019 02:35
Test infinispan
import requests
from requests.auth import HTTPBasicAuth
import time
headers = {'Content-Type': 'application/json', 'performAsync': 'True', 'timeToLiveSeconds': '99999999999'}
body = {'test':123}
auth=HTTPBasicAuth('test', 'changeme')
baseurl = "http://infinispan-server-http/rest"
@Anakin-Hao
Anakin-Hao / test.py
Created May 9, 2019 02:11
ignite test
from pyignite import Client
from pyignite.datatypes.cache_config import CacheMode
from pyignite.datatypes.prop_codes import *
from pyignite.exceptions import SocketError
import time
nodes = [('100.108.0.16',10800)]
nodes = [('100.108.0.2', 10800), ('100.108.0.5',10800), ('100.108.0.6',10800)]