Skip to content

Commit 620e825

Browse files
rhysyngsunYour Name
and
Your Name
authored
Rename the realm file to work under keycloak 26.2+ (#2209)
Co-authored-by: Your Name <[email protected]>
1 parent 2a73c52 commit 620e825

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ repos:
7575
- --exclude-files
7676
- "config/keycloak/tls/*"
7777
- --exclude-files
78-
- "config/keycloak/realms/default-realm.json"
78+
- "config/keycloak/realms/ol-local-realm.json"
7979
additional_dependencies: ["gibberish-detector"]
8080
- repo: https://github.com/astral-sh/ruff-pre-commit
8181
rev: "v0.11.4"

README-keycloak.md

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Keycloak and APISIX Integration
22

3-
The "docker-compose.services.yml" file includes Keycloak and APISIX containers that you can use for authentication instead of spinning up separate ones or using the deployed instances. It's not enabled by default, but you can run it if you prefer not to run your own Keycloak/APISIX instances.
3+
The "docker-compose.services.yml" file includes Keycloak and APISIX containers
4+
that you can use for authentication instead of spinning up separate ones or
5+
using the deployed instances. It's not enabled by default, but you can run it if
6+
you prefer not to run your own Keycloak/APISIX instances.
47

58
## Default Settings
69

710
There are some defaults that are part of this.
811

9-
_SSL Certificate_: There's a self-signed cert that's in `config/keycloak/tls` - if you'd rather set up your own (or you have a real cert or something to use), you can drop the PEM files in there. See the README there for info.
12+
_SSL Certificate_: There's a self-signed cert that's in `config/keycloak/tls` -
13+
if you'd rather set up your own (or you have a real cert or something to use),
14+
you can drop the PEM files in there. See the README there for info.
1015

11-
_Realm_: There's a `default-realm.json` in `config/keycloak` that will get loaded by Keycloak when it starts up, and will set up a realm for you with some users and a client so you don't have to set it up yourself. The realm it creates is called `ol-local`.
16+
_Realm_: There's a `ol-local-realm.json` in `config/keycloak` that will get
17+
loaded by Keycloak when it starts up, and will set up a realm for you with some
18+
users and a client so you don't have to set it up yourself. The realm it creates
19+
is called `ol-local`.
1220

1321
The users it sets up are:
1422

@@ -18,19 +26,37 @@ The users it sets up are:
1826
| `[email protected]` | `prof` |
1927
| `[email protected]` | `admin` |
2028

21-
The client it sets up is called `apisix`. You can change the passwords and get the secret in the admin.
29+
The client it sets up is called `apisix`. You can change the passwords and get
30+
the secret in the admin.
2231

2332
## Making it Work
2433

25-
The Keycloak instance is part of the `keycloak` profile in the Composer file, so if you want to interact with it, you'll need to run `COMPOSE_PROFILES=backend,frontend,keycloak,apisix docker compose up`. (If you start the app without the profile, you can still start Keycloak later by specifying the profile.)
34+
The Keycloak instance is part of the `keycloak` profile in the Composer file, so
35+
if you want to interact with it, you'll need to run
36+
`COMPOSE_PROFILES=backend,frontend,keycloak,apisix docker compose up`. (If you
37+
start the app without the profile, you can still start Keycloak later by
38+
specifying the profile.)
2639

2740
If you want to use the Keycloak and APISIX instances, follow these steps:
2841

29-
1. Change the value of `MITOL_API_BASE_URL` to `http://api.open.odl.local:8065` in your `shared.local.env` file.
30-
2. Add `MITOL_NEW_USER_LOGIN_URL=http://open.odl.local:8062/onboarding` to your `shared.local.env` file
31-
3. Copy all the env values under the "# APISIX/Keycloak " section of `backend.local.example.env` to your `backend.local.env` file. You can leave all the values as is.
32-
Remove `DISABLE_APISIX_USER_MIDDLEWARE=False` if present in your backend.local.env file.
33-
4. Keycloak needs to create its own database, which will only happen if you first destroy your current mit-learn database container: `docker compose down db`. If you prefer not to do this, you can manually create it by running the SQL in `config/postgres/init-keycloak.sql` in a postgres shell.
34-
5. Start containers with the command `COMPOSE_PROFILES=backend,frontend,keycloak,apisix docker compose up`
35-
36-
The Keycloak and APISIX containers should start up and stay running. APISIX is on port 8065, Keycloak on port 8066. Now you should be able to log in at `https://open.odl.local:8065/login` with one of the users mentioned above, or just click "Log in" from the home page at http://open.odl.local:8062. Try logging out and back in a couple times to make sure it works.
42+
1. Change the value of `MITOL_API_BASE_URL` to `http://api.open.odl.local:8065`
43+
in your `shared.local.env` file.
44+
2. Add `MITOL_NEW_USER_LOGIN_URL=http://open.odl.local:8062/onboarding` to your
45+
`shared.local.env` file
46+
3. Copy all the env values under the "# APISIX/Keycloak " section of
47+
`backend.local.example.env` to your `backend.local.env` file. You can leave
48+
all the values as is. Remove `DISABLE_APISIX_USER_MIDDLEWARE=False` if
49+
present in your backend.local.env file.
50+
4. Keycloak needs to create its own database, which will only happen if you
51+
first destroy your current mit-learn database container:
52+
`docker compose down db`. If you prefer not to do this, you can manually
53+
create it by running the SQL in `config/postgres/init-keycloak.sql` in a
54+
postgres shell.
55+
5. Start containers with the command
56+
`COMPOSE_PROFILES=backend,frontend,keycloak,apisix docker compose up`
57+
58+
The Keycloak and APISIX containers should start up and stay running. APISIX is
59+
on port 8065, Keycloak on port 8066. Now you should be able to log in at
60+
`https://open.odl.local:8065/login` with one of the users mentioned above, or
61+
just click "Log in" from the home page at http://open.odl.local:8062. Try
62+
logging out and back in a couple times to make sure it works.

0 commit comments

Comments
 (0)