-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start testing authentication with Keycloak. Fixes #86
- Loading branch information
Showing
5 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ build/ | |
dist/ | ||
*.egg-info/ | ||
*.pyc | ||
*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ services: | |
ports: | ||
- 389:389 | ||
- 636:636 | ||
|
||
db: | ||
container_name: db | ||
image: centos/postgresql-12-centos7 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
|
||
docker network create enterprise_default || echo "Moving on" | ||
|
||
docker run --rm -d -p 8080:8080 --name keycloak_server \ | ||
--network=enterprise_default \ | ||
-e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak | ||
|
||
sleep 10 | ||
|
||
KC_ADDRESS=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' keycloak_server` | ||
|
||
if [ -z "$(grep kc.example.bg /etc/hosts)" ]; then | ||
echo "--- kc.example.bg: $IP_ADDRESS --" | ||
sudo sh -c "echo '$KC_ADDRESS kc.example.bg' >> /etc/hosts" | ||
fi | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth \ | ||
--realm master --user admin --password admin | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh create realms -s realm=kiwi -s enabled=true | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh create clients \ | ||
-r kiwi -s clientId=kiwitcms-web-app -s enabled=true -s protocol=openid-connect \ | ||
-s attributes='{"user.info.response.signature.alg": "RS256"}' \ | ||
-s publicClient=false -s rootUrl=https://testing.example.bg:8443 -o > kc_client.json | ||
KC_CLIENT_ID=`cat kc_client.json | jq -r '.id'` | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh create clients/$KC_CLIENT_ID/protocol-mappers/models \ | ||
-r kiwi -s name="Audience Mapper" -s protocol=openid-connect \ | ||
-s protocolMapper=oidc-audience-mapper \ | ||
-s config='{"included.client.audience": "kiwitcms-web-app"}' | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh get keys -r kiwi > kc_realm_keys.json | ||
KC_PUBLIC_KEY=`cat kc_realm_keys.json | jq -r '.keys | .[] | select(.algorithm | contains("RS256")) | .publicKey'` | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh get clients/$KC_CLIENT_ID/client-secret -r kiwi > kc_client_secret.json | ||
KC_CLIENT_SECRET=`cat kc_client_secret.json | jq -r '.value'` | ||
|
||
echo "KC_PUBLIC_KEY=\"$KC_PUBLIC_KEY\"" > /tmp/kc.env | ||
echo "KC_CLIENT_SECRET=\"$KC_CLIENT_SECRET\"" >> /tmp/kc.env | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh create users -r kiwi -s username=kc_bot -s enabled=false | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh create users -r kiwi -s username=kc_atodorov -s enabled=true \ | ||
-s email=atodorov@kc.example.bg -o --fields id > kc_atodorov.json | ||
|
||
cat kc_atodorov.json | ||
KC_USER_ID=`cat kc_atodorov.json | jq -r ".id"` | ||
|
||
docker exec -i keycloak_server \ | ||
/opt/jboss/keycloak/bin/kcadm.sh update users/$KC_USER_ID/reset-password \ | ||
-r kiwi -s type=password -s value=h3llo-w0rld -s temporary=false -n |