Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Keycloak Admin configurable #9490

Merged
3 commits merged into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions deploy/openshift/templates/multi/keycloak-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ objects:
- name: POSTGRES_PASSWORD
value: keycloak
- name: KEYCLOAK_USER
value: admin
value: "${KEYCLOAK_USER}"
- name: KEYCLOAK_PASSWORD
value: admin
value: "${KEYCLOAK_PASSWORD}"
- name: PROTOCOL
value: "${PROTOCOL}"
- name: ROUTING_SUFFIX
Expand Down Expand Up @@ -140,10 +140,20 @@ objects:
storage: 1Gi

parameters:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this empty line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks

- name: PROTOCOL
displayName: htpps or http protocol
description: Protocol to be used in Che communications
value: http
- name: KEYCLOAK_USER
displayName: Keycloak admin user
description: Default Keycloak admin user
value: "admin"
- name: KEYCLOAK_PASSWORD
displayName: Keycloak admin password
description: Default Keycloak admin password. Can be changed after login
value: "admin"
value: http

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this line is a typo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks

- name: ROUTING_SUFFIX
displayName: Routing suffix of your OpenShift cluster
description: This is the suffix appended to routes in your OpenShift cluster <route>.<project>.<routing_suffix>
Expand Down
9 changes: 6 additions & 3 deletions dockerfiles/keycloak/kc_realm_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ cat /scripts/che-users-0.json.erb | \
sed -e "/<% end -%>/d" | \
sed -e "/\"requiredActions\" : \[ \],/d" > /scripts/che-users-0.json

cp /scripts/master-users-0.json.erb /scripts/master-users-0.json
cp /scripts/master-realm.json.erb /scripts/master-realm.json

if [ "${CHE_KEYCLOAK_ADMIN_REQUIRE_UPDATE_PASSWORD}" == "false" ]; then
sed -i -e "s#\"UPDATE_PASSWORD\"##" /scripts/che-users-0.json
fi
Expand All @@ -24,6 +21,12 @@ cat /scripts/che-realm.json.erb | \
sed -e "s@<%= scope\.lookupvar('che::che_server_url') %>@${PROTOCOL}://che-${NAMESPACE}.${ROUTING_SUFFIX}@" \
> /scripts/che-realm.json

echo "Creating Admin user..."

if [ $KEYCLOAK_USER ] && [ $KEYCLOAK_PASSWORD ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

! -z ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically reused this https://github.com/jboss-dockerfiles/keycloak/blob/3.3.0.CR2-3/server/docker-entrypoint.sh

In fact, even a check isn't really required since ENVS are set in deploymentConfig.

/opt/jboss/keycloak/bin/add-user-keycloak.sh --user $KEYCLOAK_USER --password $KEYCLOAK_PASSWORD
fi

echo "Starting Keycloak server..."

/opt/jboss/keycloak/bin/standalone.sh -Dkeycloak.migration.action=import \
Expand Down