Example Keycloak config.
This commit is contained in:
parent
c85b29c237
commit
5920602eb0
@ -16,3 +16,4 @@ cerc/watcher-mobymask
|
|||||||
cerc/test-container
|
cerc/test-container
|
||||||
cerc/eth-probe
|
cerc/eth-probe
|
||||||
cerc/builder-js
|
cerc/builder-js
|
||||||
|
cerc/keycloak
|
||||||
|
@ -13,3 +13,4 @@ fixturenet-eth
|
|||||||
watcher-mobymask
|
watcher-mobymask
|
||||||
test
|
test
|
||||||
eth-probe
|
eth-probe
|
||||||
|
keycloak
|
||||||
|
37
compose/docker-compose-keycloak.yml
Normal file
37
compose/docker-compose-keycloak.yml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
keycloak-db:
|
||||||
|
image: postgres:14-alpine
|
||||||
|
env_file:
|
||||||
|
- ../config/keycloak/keycloak.env
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-v", "localhost", "5432"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 10
|
||||||
|
start_period: 3s
|
||||||
|
ports:
|
||||||
|
- 5432
|
||||||
|
keycloak:
|
||||||
|
image: cerc/keycloak:latest
|
||||||
|
env_file:
|
||||||
|
- ../config/keycloak/keycloak.env
|
||||||
|
environment:
|
||||||
|
JAVA_OPTS_APPEND: "-Dkeycloak.migration.action=import -Dkeycloak.migration.provider=dir -Dkeycloak.migration.dir=/import -Dkeycloak.migration.strategy=IGNORE_EXISTING"
|
||||||
|
volumes:
|
||||||
|
- ../config/keycloak/import:/import
|
||||||
|
ports:
|
||||||
|
- 8080
|
||||||
|
command: ["start"]
|
||||||
|
depends_on:
|
||||||
|
keycloak-db:
|
||||||
|
condition: service_healthy
|
||||||
|
keycloak-nginx:
|
||||||
|
image: nginx:1.23-alpine
|
||||||
|
volumes:
|
||||||
|
- ../config/keycloak/nginx:/etc/nginx/conf.d
|
||||||
|
ports:
|
||||||
|
- 80
|
||||||
|
depends_on:
|
||||||
|
- keycloak
|
1627
config/keycloak/import/cerc-realm.json
Normal file
1627
config/keycloak/import/cerc-realm.json
Normal file
File diff suppressed because it is too large
Load Diff
16
config/keycloak/keycloak.env
Normal file
16
config/keycloak/keycloak.env
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
POSTGRES_DB=keycloak
|
||||||
|
POSTGRES_USER=keycloak
|
||||||
|
POSTGRES_PASSWORD=keycloak
|
||||||
|
KC_DB=postgres
|
||||||
|
KC_DB_URL_HOST=keycloak-db
|
||||||
|
KC_DB_URL_DATABASE=${POSTGRES_DB}
|
||||||
|
KC_DB_USERNAME=${POSTGRES_USER}
|
||||||
|
KC_DB_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
|
KC_DB_SCHEMA=public
|
||||||
|
KC_HOSTNAME=keycloak
|
||||||
|
KC_HTTP_ENABLED="true"
|
||||||
|
KC_HTTP_RELATIVE_PATH="/auth"
|
||||||
|
KC_HOSTNAME_STRICT_HTTPS="false"
|
||||||
|
KEYCLOAK_ADMIN=admin
|
||||||
|
KEYCLOAK_ADMIN_PASSWORD=admin
|
||||||
|
REALM_NAME=cerc
|
30
config/keycloak/nginx/keycloak_proxy.conf
Normal file
30
config/keycloak/nginx/keycloak_proxy.conf
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/v1/([^/]*)$ {
|
||||||
|
set $apiKey $1;
|
||||||
|
auth_request /auth;
|
||||||
|
proxy_buffering off;
|
||||||
|
rewrite /.*$ / break;
|
||||||
|
proxy_pass http://fixturenet-eth-geth-1:8545;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /auth {
|
||||||
|
internal;
|
||||||
|
proxy_buffering off;
|
||||||
|
resolver 127.0.0.11 ipv6=off;
|
||||||
|
proxy_pass http://keycloak:8080/auth/realms/cerc/check?apiKey=$apiKey;
|
||||||
|
proxy_pass_request_body off;
|
||||||
|
proxy_set_header Content-Length "";
|
||||||
|
proxy_set_header X-Original-URI $request_uri;
|
||||||
|
proxy_set_header X-Original-Remote-Addr $remote_addr;
|
||||||
|
proxy_set_header X-Original-Host $host;
|
||||||
|
}
|
||||||
|
}
|
10
container-build/cerc-keycloak/Dockerfile
Normal file
10
container-build/cerc-keycloak/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM maven:3-eclipse-temurin-11-alpine AS builder
|
||||||
|
RUN apk add --update --no-cache git
|
||||||
|
WORKDIR /build
|
||||||
|
RUN git clone https://github.com/cerc-io/keycloak-api-key-demo.git
|
||||||
|
RUN cd keycloak-api-key-demo && \
|
||||||
|
git checkout 81d0a443c363cb55df2c90e3b13fc5a4710197ba && \
|
||||||
|
mvn -f api-key-module package
|
||||||
|
|
||||||
|
FROM quay.io/keycloak/keycloak:19.0.2
|
||||||
|
COPY --from=builder /build/keycloak-api-key-demo//api-key-module/target/deploy/* /opt/keycloak/providers/
|
8
container-build/cerc-keycloak/build.sh
Executable file
8
container-build/cerc-keycloak/build.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
#Build cerc/keycloack
|
||||||
|
|
||||||
|
# See: https://stackoverflow.com/a/246128/1701505
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
docker build -t cerc/keycloak:local ${SCRIPT_DIR}
|
Loading…
Reference in New Issue
Block a user