Skip to content

Instantly share code, notes, and snippets.

@xgp
xgp / keycloak-mssql-docker-compose.yml
Created April 12, 2023 19:50
running keycloak with mssql using docker-compose
version: '3'
volumes:
mssql_data:
driver: local
caddy_data:
driver: local
services:
mssql:
@xgp
xgp / openapi.yaml
Last active April 22, 2024 16:45
OpenAPI specification for Keycloak account API
openapi: 3.0.2
info:
title: Keycloak Account API
version: 20.0.3
description: |
Derived from the code at https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/services/resources/account/AccountRestService.java
components:
securitySchemes:
access_token:
type: http
@xgp
xgp / org-create.sh
Created October 6, 2022 15:26
Example to create org
#!/bin/bash
read -p 'Host (format https://euc1.auth.ac ): ' host
read -p 'Realm: ' realm
printf "\nThis user must have create-organization, manage-organizations, and view-organizations realm-management roles in order to create and manage new Organizations.\n"read -p 'Username: ' user
read -p 'Username: ' user
read -sp 'Password: ' pass
DIRECT_GRANT_RESPONSE=$(curl -i --request POST $host/auth/realms/$realm/protocol/openid-connect/token --header "Accept: application/json" --header "Content-Type: application/x-www-form-urlencoded" --data "grant_type=password&username=$user&password=$pass&client_id=admin-cli")
@xgp
xgp / Dockerfile
Last active April 23, 2024 13:01
Keycloak 17 example using JGroups JDBC_PING discovery protocol for Infinispan
FROM quay.io/keycloak/keycloak:17.0.0 as builder
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=preview
ENV KC_DB=postgres
ENV KC_HTTP_RELATIVE_PATH=/auth
# specify the custom cache config file here
ENV KC_CACHE_CONFIG_FILE=cache-ispn-jdbc-ping.xml
# copy the custom cache config file into the keycloak conf dir
@xgp
xgp / ExampleTest.java
Created October 28, 2021 08:55
JUnit4 Keycloak Rule
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.representations.idm.RealmRepresentation;
public class ExampleTest {
@xgp
xgp / gist:a853e80351e832070511a8ec7d0fda78
Last active December 7, 2016 10:57
Using swagger codegen Java with APIs that require 2- or 3-legged OAuth1
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import se.akerfeldt.okhttp.signpost.SigningInterceptor;
....
// Using the default Java
DefaultApi api = new DefaultApi();
ApiClient client = api.getApiClient();
// Put the interceptor in the http client
OkHttpClient http = client.getHttpClient();
#!/bin/bash
echo '=================================================='
echo '===============Install necessary tools==============='
echo '=================================================='
sudo yum update
sudo yum install git make flex bison libtool automake openssl-devel libevent libevent-devel python-devel gcc-c++ byacc java-1.7.0-openjdk ant
echo '=================================================='