-
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
1 parent
7e08e44
commit dfe94de
Showing
46 changed files
with
1,557 additions
and
151,086 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 |
---|---|---|
@@ -1,104 +1,34 @@ | ||
# ontodocker | ||
|
||
Prerequisites: Docker and docker-compose | ||
Prerequisites: Docker and docker compose | ||
|
||
### Keycloak installation and configurations | ||
|
||
**You must configure Keycloak first!** | ||
|
||
Go to the keycloak directory, edit password in `Dockerfile` and `docker-compose.yml`. | ||
|
||
Start Keycloak container with | ||
```bash | ||
docker-compose up -d --build | ||
``` | ||
in the terminal (cmd) | ||
|
||
check the status | ||
```bash | ||
docker-compose logs keycloak | ||
``` | ||
|
||
After the start, (You have to wait until Keycloak is completely ready and you'll see the line `Running the server in development mode. DO NOT use this configuration in production.` in terminal.) | ||
|
||
go to http://localhost:8080, enter the admin password set in the `Dockerfile`, then you'll see the homepage of Keycloak | ||
|
||
![Keycloak Homepage](source/images/keycloak_homepage.PNG "Keycloak Homepage") | ||
|
||
Now we need to create a client for our application. | ||
|
||
1. Fill in the basic information, e.g. email, name (we need this). And then Save | ||
![Keycloak Admin User](source/images/keycloak_admin_user.PNG "Keycloak Admin User Edit") | ||
|
||
2. Create client for our application | ||
![Keycloak Create Client](source/images/keycloak_client.PNG "Keycloak Create Client") | ||
![Keycloak Create Client2](source/images/keycloak_client2.PNG "Keycloak Create Client2") | ||
![Keycloak Create Client3](source/images/keycloak_client3.PNG "Keycloak Create Client3") | ||
3. Get client secret (client secret is required .env) | ||
![Keycloak Client Secret](source/images/keycloak_client_secret.PNG "Keycloak Client Secret") | ||
4. Use roles to control access to the application | ||
|
||
create Realm roles: `App-admin`, `App-insider`, `App-guest` | ||
|
||
(If you don't know what roles mean in Keycloak, see https://stackoverflow.com/questions/47837613/how-are-keycloak-roles-managed) | ||
|
||
![Keycloak Create Role](source/images/keycloak_role1.PNG "Keycloak Create Role") | ||
![Keycloak Create Role](source/images/keycloak_role2.PNG "Keycloak Create Role") | ||
![Keycloak Create Role](source/images/keycloak_role3.PNG "Keycloak Create Role") | ||
|
||
Now we're going to assign roles to users, e.g., assign `App-insider` role to user `test_insider` | ||
![Keycloak Users](source/images/keycloak_role4.PNG "Keycloak Users") | ||
![Keycloak Assign Role](source/images/keycloak_role5.PNG "Keycloak Assign Role") | ||
As you can see, the "admin" role is already created by keycloak by default. The `App-admin` role was created for demo purposes and has the same effect as the `admin` role. | ||
|
||
Make sure that client scope `roles` is assigned to the client `glass`, if not, add the client scope `roles` to `glass` | ||
![Keycloak Client Scopes](source/images/keycloak_role6.PNG "Keycloak Client Scopes") | ||
Now go to Client scopes (left panel), enter roles page: | ||
5. | ||
![Keycloak Client Scopes](source/images/keycloak_role7.PNG "Keycloak Client Scopes") | ||
![Keycloak Client Scopes](source/images/keycloak_role8.PNG "Keycloak Client Scopes") | ||
modify `realm roles` & `client roles` as below: | ||
![Keycloak Client scope details](source/images/keycloak_role9.PNG "Keycloak Client scope details") | ||
![Keycloak realm roles](source/images/keycloak_role10.PNG "Keycloak realm roles") | ||
![Keycloak client roles](source/images/keycloak_role11.PNG "Keycloak client roles") | ||
Apparently we only use the realm roles, but it can't hurt to set client roles together | ||
|
||
|
||
**Now you have done the Keycloak configuration part!** | ||
|
||
### ontodocker installation | ||
### Ontodocker installation | ||
|
||
Once you have done the keycloak configuration part. Go back to the parent directory (`cd ..`) | ||
|
||
Create a `.env` file with the following contents and fill or change them accordingly. | ||
``` | ||
ONTODOCKER_RUN_PORT=8000 | ||
ADMIN_EMAIL= | ||
JWT_SECRET_KEY= | ||
JWT_DEFAULT_DAYS_VALID=90 | ||
JWT_MIN_DAYS_VALID=1 | ||
JWT_MAX_DAYS_VALID=90 | ||
MAX_SESSION_TIME_IN_DAYS=14 | ||
FUSEKI_ADMIN_USER=admin | ||
FUSEKI_ADMIN_PW=changeme | ||
APP_URI=http://fastapi:8000 | ||
KEYCLOAK_HOST=http://keycloak:8080 | ||
KEYCLOAK_REALM=master | ||
KEYCLOAK_CLIENT_ID=ontodocker | ||
KEYCLOAK_CLIENT_SECRET= | ||
KEYCLOAK_ROLES_ADMIN=App-admin,admin | ||
KEYCLOAK_ROLES_RW=App-insider | ||
KEYCLOAK_ROLES_RO=App-guest | ||
ALLOW_UNAUTHORIZED_READONLY_API_ACCESS=false | ||
ALLOW_UNAUTHORIZED_READONLY_UI_ACCESS=true | ||
ANONYMOUS_IS_ADMIN=false | ||
``` | ||
|
||
Create a random key for `JWT_SECRET_KEY` by excecuting | ||
``` | ||
openssl rand -hex 36 | ||
``` | ||
in a command line and fill the line in the `.env` file. | ||
in a command line and fill the line in the `.env` file or use another randomized string. | ||
|
||
Important: If you start the application for the first time set `ANONYMOUS_IS_ADMIN` to `true` and `ALLOW_UNAUTHORIZED_READONLY_UI_ACCESS` to `true`. That will give you administration access to configure local users or SSO Providers (like Keycloak (description below)) in the Administration interface. | ||
If you only need a local developing instance you can also fully use the anonymous user except for saving SPARQL queries. | ||
|
||
Edit the Fuseki admin password (`ADMIN_PASSWORD`) as well and `JAVA_OPTIONS` for Java Virtual Machine (JVM) memory settings in `docker-compose-dev.yml`. | ||
|
||
|
@@ -109,24 +39,54 @@ ln -s docker-compose-dev.yml docker-compose.yml | |
|
||
Build the docker container with | ||
```bash | ||
docker-compose build | ||
docker compose build | ||
``` | ||
|
||
Start the docker container with | ||
```bash | ||
docker-compose up -d | ||
docker compose up -d | ||
``` | ||
|
||
Watch the logs with | ||
```bash | ||
docker-compose logs -f | ||
docker compose logs -f | ||
``` | ||
Now you may go to http://localhost:8000 | ||
|
||
### Keycloak installation and configurations (optional) | ||
|
||
Go to the keycloak directory, edit password in `Dockerfile` and `docker-compose.yml`. And watch for the KC_HOSTNAME_URL if you plan to access keycloaks admin interface from a different IP. | ||
|
||
Start Keycloak container with | ||
```bash | ||
docker compose up -d --build | ||
``` | ||
in the terminal (cmd) | ||
|
||
check the status | ||
```bash | ||
docker compose logs -f keycloak | ||
``` | ||
|
||
After the start, (You have to wait until Keycloak is completely ready and you'll see the line `Running the server in development mode. DO NOT use this configuration in production.` in terminal.) | ||
|
||
go to http://localhost:8080 (or your IP where you installed the keycloak), enter the admin password set in the `Dockerfile`, then you'll see the homepage of Keycloak | ||
|
||
![Keycloak Homepage](source/images/keycloak_homepage.PNG "Keycloak Homepage") | ||
|
||
Now we need to create a client for our application. | ||
|
||
|
||
1. Create client for your application (in screenshot the client id is `glass` but you can name it whatever you want). | ||
Also be sure that the valid redirect URL contains the port (default e.g. 8000, like `http://{yourip}:8000/*`) | ||
![Keycloak Create Client](source/images/keycloak_client.PNG "Keycloak Create Client") | ||
![Keycloak Create Client2](source/images/keycloak_client2.PNG "Keycloak Create Client2") | ||
![Keycloak Create Client3](source/images/keycloak_client3.PNG "Keycloak Create Client3") | ||
3. Get client secret | ||
![Keycloak Client Secret](source/images/keycloak_client_secret.PNG "Keycloak Client Secret") | ||
|
||
The .well-known URL is normally `http://{your_keycloak_ip}:8080/realms/master/.well-known/openid-configuration` | ||
Apparently we only use the realm roles, but it can't hurt to set client roles together | ||
|
||
## Authors & Acknowledgment | ||
Robert Heimsoth (DECOIT GmbH & Co. KG) | ||
Jannis Grundmann (Leibniz-Institut für Werkstofforientierte Technologien - IWT) | ||
|
||
Based on FastOntodocker by Ya-Fan Chen ([email protected]) | ||
**Now you have done the Keycloak configuration!** |
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
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
Oops, something went wrong.