This application is used to configure Keycloak+Kong installations, locally or as part of a cluster.
An app represents an application and defines a set of public URLs. The main difference between an app and a service is that the app cannot be added to a realm.
Continues in App README
A service represents an application and defines a set of public and protected URLs and the routes to access to them.
Continues in Service README
A solution gathers a set of services.
Continues in Solution README
All the commands are defined in the entrypoint.sh
file.
entrypoint.sh {command-name} {rest-of-arguments}
Shows the help message with all the possible commands.
Runs bash inside the container.
Evals shell command inside the container.
Checks the Keycloak connection. Returns status 0
on success.
Adds a new realm in Keycloak using a default realm template.
add_realm {realm} {description (optional)} {login theme (optional)}
Adds a user to an existing realm in Keycloak.
add_user {realm} {username} \
{*password} {*is_administrator} \
{*email} {*reset_password_on_login}
Adds a confidential client to an existing realm in Keycloak. Required for any realm that will use OIDC for authentication.
add_confidential_client {realm} {client-name}
# or
add_oidc_client {realm} {client-name}
Adds a public client to an existing realm in Keycloak. Allows token generation.
add_public_client {realm} {client-name}
Decodes a Keycloak JSON Web Token (JWT).
decode_token {token}
Checks the Kong connection. Returns status 0
on success.
Registers an app as a service in Kong,
using the app definition in APPS_PATH
directory.
add_app {app-name}
# or
register_app {app-name}
Note: The expected app file is
{APPS_PATH}/{app-name}.json
.
Removes an app in Kong,
using the app definition in APPS_PATH
directory.
remove_app {app-name}
Note: The expected app file is
{APPS_PATH}/{app-name}.json
.
Adds a service to an existing realm in Kong,
using the service definition in SERVICES_PATH
directory.
add_service {service-name} {realm} {oidc-client}
Note: The expected service file is
{SERVICES_PATH}/{service-name}.json
.
Removes a service from an existing realm in Kong,
using the service definition in SERVICES_PATH
directory.
remove_service {service-name} {realm}
# removes service from all realms
remove_service {service-name}
# or
remove_service {service-name} "*"
Note: The expected service file is
{SERVICES_PATH}/{service-name}.json
.
Note: the service will not be enterily removed if it's still used by another realm.
Adds a package of services to an existing realm in Kong,
using the solution definition in SOLUTION_PATH
directory.
add_solution {solution-name} {realm} {oidc-client}
Note: The expected solution file is
{SOLUTION_PATH}/{solution-name}.json
.
Removes a package of services from an existing realm in Kong,
using the solution definition in SOLUTION_PATH
directory.
remove_solution {solution-name} {realm}
# removes solution from all realms
remove_solution {solution-name}
# or
remove_solution {solution-name} "*"
Note: The expected solution file is
{SOLUTION_PATH}/{solution-name}.json
.
Note: the solution will not be enterily removed if it's still used by another realm.
Adds a Superuser to the Kafka Cluster.
add_kafka_su {username} {password}
Gives an existing user superuser status.
grant_kafka_su {username}
Adds a kafka user for a tenant, and adds ACL to their namespace.
add_kafka_tenant {tenant}
Gets SASL Credential for a given kafka tenant.
get_kafka_creds {tenant}
Note: You need the following environment variables to be set to manipulate CCloud.
- CC_API_USER : a permissioned Confluent Cloud User
- CC_API_PASSWORD: that user's password
- CC_ENVIRONMENT_NAME: the name of the environment you want to use (or default)
- CC_CLUSTER_NAME: the name of the cluster to modify
Adds a Superuser to the Confluent Cloud Kafka Cluster.
add_ccloud_su {username} {password}
Gives an existing user superuser status.
grant_ccloud_su {username}
Removes a Superuser and their credentials, account and permissions.
delete_ccloud_su {username}
Adds a kafka user for a tenant, and adds ACL to their namespace.
add_ccloud_tenant {tenant}
Removes a tenant and their credentials, account and permissions (Does not remove data / topics).
delete_ccloud_tenant {username}
Adds a ccloud APIKey for a tenant.
add_ccloud_key {tenant} "{description (optional)}"
Lists previously registered tenants in CCloud cluster.
list_ccloud_tenants
Lists ACLs of CCloud tenants, or of a single tenant referenced by name
list_ccloud_acls {tenant (optional) }
Lists active APIKeys on the cluster. (Names only)
list_ccloud_api_keys
Checks the ElasticSearch connection. Returns status 0
on success.
Prepares ElasticSearch.
setup_elasticsearch
Adds a tenant to ElasticSearch.
add_elasticsearch_tenant {tenant}
-
DEBUG
: Enables debug mode. Isfalse
if unset or set to empty string, anything else is consideredtrue
. -
BASE_DOMAIN
: Installation hostname. -
BASE_HOST
: Installation hostname with protocol. -
APPS_PATH
: Path to app files directory. Defaults to/code/app
. -
SERVICES_PATH
: Path to service files directory. Defaults to/code/service
. -
SOLUTIONS_PATH
: Path to solution files directory. Defaults to/code/solution
.
-
TEMPLATES_PATH
: Path to template files directory. Defaults to/code/templates
. -
CORS_TEMPLATE_PATH
: Path to Kong service CORS plugin template file. This template is used with theregister_app
command. Defaults to{TEMPLATES_PATH}/cors_template.json
. -
OIDC_TEMPLATE_PATH
: Path to Kong service OIDC plugin template file. This template is used with theadd_service
andadd_solution
commands. Defaults to{TEMPLATES_PATH}/oidc_template.json
. -
REALM_TEMPLATE_PATH
: Path to keycloak realm template file. This template is used with theadd_solution
andadd_service
commands. Defaults to{TEMPLATES_PATH}/realm_template.json
. -
CLIENT_TEMPLATE_PATH
: Path to keycloak client template file. This template is used with theadd_confidential_client
,add_oidc_client
andadd_public_client
commands. Defaults to{TEMPLATES_PATH}/client_template.json
. -
ADMIN_TEMPLATE_PATH
: Path to Keycloak admin user template file. This template is used with theadd_user
command while creating admin users. Defaults to{TEMPLATES_PATH}/user_admin_template.json
. -
USER_TEMPLATE_PATH
: Path to Keycloak standard user template file. This template is used with theadd_user
command while creating non admin users. Defaults to{TEMPLATES_PATH}/user_standard_template.json
. -
ES_ROLE_TEMPLATE_PATH
: Path to ElasticSearch role template file. This template is used with theadd_elasticsearch_tenant
command. Defaults to{TEMPLATES_PATH}/es_role_template.json
.
All of these templates are going to be parsed using the
python template strings feature.
This means that even the keys or the values can contain $-based
strings that
will be replaced with the environment variable or command argument values.
Some of the expected $-based
strings are:
domain
: replaced withBASE_DOMAIN
environment variable value.host
: replaced withBASE_HOST
environment variable value.realm
: replaced with therealm
command argument value.tenant
: replaced with thetenant
command argument value.publicRealm
: replaced withPUBLIC_REALM
environment variable value.oidc_client_id
: replaced with theoidc-client
command argument value.oidc_client_secret
: replaced withoidc
client secret fetched form Keycloak.username
: replaced with theusername
command argument value.email
: replaced with theemail
command argument value.
Review the code to get the expected strings in each case.
KEYCLOAK_INTERNAL
: Keycloak internal URL. Usuallyhttp://keycloak:8080/auth/
. Note: Ending/
is required to connect to admin console.KEYCLOAK_MASTER_REALM
: Keycloak master realm name. Defaults tomaster
.KEYCLOAK_GLOBAL_ADMIN
: Keycloak admin user name in the master realm.KEYCLOAK_GLOBAL_PASSWORD
: Keycloak admin user password in the master realm.
KONG_INTERNAL
: Kong internal URL. Usuallyhttp://kong:8001
.PUBLIC_REALM
: Kong public realm. Defaults to-
.
ZOOKEEPER_HOST
: Zookeeper host address. Usually127.0.0.1:32181
.ZOOKEEPER_USER
: Zookeeper user name.ZOOKEEPER_PW
: Zookeeper user password.KAFKA_SECRET
: Kafka registered administrative credentials.
ELASTICSEARCH_HOST
: Elasticsearch internal URL. Usuallyhttp://elasticsearch:9200
.ELASTICSEARCH_USER
: Elasticsearch user name.ELASTICSEARCH_PW
: Elasticsearch user password.