forked from ravthiru/keycloak-recepies
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
set -o pipefail | ||
|
||
PATH=/opt/jboss/keycloak/bin:$PATH | ||
|
||
|
||
authurl=http://localhost:8080/auth | ||
|
||
authcmd() { | ||
kcadm.sh config credentials --server $authurl --realm master --user admin --password admin | ||
} | ||
|
||
echo Waiting for Keycloak to become ready while we try and get an access token | ||
while ! authcmd; do | ||
sleep 3 | ||
done | ||
|
||
echo Logged in | ||
|
||
echo Configuring Keycloak... | ||
|
||
kcadm.sh create realms -s realm=springboot-keycloak -s id=springbook-keycloak -s displayName=springboot-keycloak -s enabled=true -s sslRequired=external | ||
|
||
kcadm.sh create clients -r springboot-keycloak -s bearerOnly=true -s clientId=employee-service-app -s enabled=true | ||
|
||
kcadm.sh create clients -r springboot-keycloak -s clientId=automation-tester -s publicClient=true -s protocol=openid-connect -s "redirectUris=[\"http://localhost:8081/*\"]" -s enabled=true | ||
|
||
#kcadm.sh create roles -r springboot-keycloak -s name=user -o -s 'description=Allows access to get employee details.' | ||
|
||
|
||
kcadm.sh create users -r springboot-keycloak -s username=test-user -s enabled=true | ||
|
||
kcadm.sh set-password -r springboot-keycloak --username test-user --new-password test123 | ||
|
||
|
||
#kcadm.sh add-roles --uusername test-user --rolename user -r springboot-keycloak |
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,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
### constants ################################################################## | ||
|
||
path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
KEYCLOAK_VERSION="11.0.2" | ||
IMAGE_NAME="quay.io/keycloak/keycloak" | ||
|
||
|
||
### Run Test cases ################################################### | ||
|
||
chmod a+x $path/config/keycloak-init.sh | ||
|
||
docker stop keycloak || true | ||
|
||
docker run --rm -itd -p 8080:8080 \ | ||
--name=keycloak \ | ||
-e KEYCLOAK_USER=admin \ | ||
-e KEYCLOAK_PASSWORD=admin \ | ||
-v "$path/config":/opt/jboss/config \ | ||
"$IMAGE_NAME:$KEYCLOAK_VERSION" | ||
|
||
docker exec -it --user 1000 keycloak /usr/bin/sh -c /opt/jboss/config/keycloak-init.sh | ||
|
||
# docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:11.0.2 | ||
|
||
#docker run -itd --name=myContainer myImage /bin/bash | ||
#docker exec -it myContainer /bin/bash -c /init.sh |