Keycloak server is the Identity broker used for BAND.
Keycloak server is the Identity broker used for BAND.
The server is a Ubuntu machine.You may need a public IP and proper domain name for your own Keycloak server.
The server is a Ubuntu machine.You may need a public IP and proper domain name for your own Keycloak server.
You will need a server ready with proper DNS name for the public facing portal, before configuring keyloak.
You will need a server ready with proper DNS name for the public facing portal, before configuring keyloak.
**Installation**
**Installation**
1. install docker engine on the machine. [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04)
1. install docker engine on the machine. [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04)
2. install nginx
2. install nginx
```text
```text
apt-get update -y & apt-get install -y nginx
apt-get update -y & apt-get install -y nginx
```
```
3\. Obtain SSL certificates from IT or Letsencrypt
3\. get a DNS name from https://docs.egi.eu/users/compute/cloud-compute/dynamic-dns/
3\. Obtain SSL certificates from Letsencrypt or https://certbot.eff.org
7\. pull keycloak container. Note that the currently keycloak version used is 4.5.0Final which is pretty old and due to upgrade. A more recent version would be better, but this will be a future work
7\. pull keycloak container. Note that the currently keycloak version used is 4.5.0Final which is pretty old and due to upgrade. A more recent version would be better, but this will be a future work
8\. configure nginx. remove default from /etc/nginx/site-enabled, add a file 'ssl' with the below content to /etc/nginx/site-available and enable it.
8\. configure nginx. remove default from /etc/nginx/site-enabled, add a file 'ssl' with the below content to /etc/nginx/site-available and enable it.
* User Info URL: https://proxy.aai.lifescience-ri.eu/OIDC/userinfo
7\. Create your own keyloak login flow extension, compile it as jar file and copy keycloak-flow-extension.jar to /opt/jboss/keycloak/standalone/deployments inside the keycloak container.
* Default Scopes: openid email profile
* Permission tab: enabled
This article will be of help on creating keylcoak extensions https://andrebiegel.github.io/projects/2021/08/28/keycloak-extensions.html
7\. Create your own keyloak login flow extension, compile it as jar file and copy keycloak-flow-extension.jar to /opt/jboss/keycloak/standalone/deployments inside the keycloak container.
8\. Create your own login them, and copy it into keycloak container (https://www.keycloak.org/docs/latest/server_development/)
This article will be of help on creating keylcoak extensions https://andrebiegel.github.io/projects/2021/08/28/keycloak-extensions.html
9\. restart keycloak container
8\. Create your own login them, and copy it into keycloak container (https://www.keycloak.org/docs/latest/server_development/)
10.login into the keycloak container, check /etc/hosts. it should contain the correct LDAP server IP
9\. restart keycloak container
**Configuration via Keycloak admin interface**
10.login into the keycloak container, check /etc/hosts. it should contain the correct LDAP server IP
[Refer to Keycload documentations](https://www.keycloak.org/docs/latest/server_admin/)
**Configuration via Keycloak admin interface**
The below steps are examples used in BAND, if your client names are different, change accordingly.
[Refer to Keycload documentations](https://www.keycloak.org/docs/latest/server_admin/)
1. create realm name
1. endpoints: OpenID Endpoint Configuration
The below steps are examples used in BAND, if your client names are different, change accordingly.
2. Login tabs: all OFF
3. Themes: name_of_your_theme
1. create realm name
2. create following clients.
1. endpoints: OpenID Endpoint Configuration
1. eosc-client
2. Login tabs: all OFF
1. set to ON for "Enabled, Standard Flow Enabled, Direct Access Grants Enabled", leave the rest OFF
3. Themes: name_of_your_theme
2. Valid redirect URIs:
2. create following clients.
1. https://band.embl.de/*
1. eosc-client
2. https://band.embl.de/eosc/*
1. set to ON for "Enabled, Standard Flow Enabled, Direct Access Grants Enabled", leave the rest OFF
3. https://band.embl.de/eosc/api/linked
2. Valid redirect URIs:
4. create Token Mappers
1. https://band.embl.de/*
* email -> User Property, Token claim: email, Property: email
* given name ->User Property, Token claim:given\_name, Property: firstName
* openid ->RealmProperty, Token claim: openid, Realm role prefix: openid
2. resource
* family name ->User Property, Token claim: family\_name, Property: lastName
1. set to ON for "Enabled, Standard Flow Enabled, Direct Access Grants Enabled, Service Accounts Enabled, authorization Enabled", leave the rest OFF
* full name -> User's full name
2. valid redirect URI
* given name ->User Property, Token claim:given\_name, Property: firstName
1. https://band.embl.de/*
2. resource
2. https://band.embl.de/kc/api/*
1. set to ON for "Enabled, Standard Flow Enabled, Direct Access Grants Enabled, Service Accounts Enabled, authorization Enabled", leave the rest OFF
3. https://band.embl.de/resource
2. valid redirect URI
4. create Token Mappers (same as eosc-client)
1. https://band.embl.de/*
3. service account roles. eosc and user role are created via Roles page
2. https://band.embl.de/kc/api/*
1. eosc
3. https://band.embl.de/resource
2. user
4. create Token Mappers (same as eosc-client)
3. offline\_access
3. service account roles. eosc and user role are created via Roles page
4. uma\_authorization
1. eosc
4. Scope: full scope allowed
2. user
3. User Federation:
3. offline\_access
1. these are settings connect to ldap server
4. uma\_authorization
1. username LDAP attribute: uid
4. Scope: full scope allowed
2. RDN: cn
3. User Federation:
3. UUID: uid
1. these are settings connect to ldap server
4. User object classes: inetOrgPerson, organizationalPerson
1. username LDAP attribute: uid
5. user DN:ou=users,dc=eosc-life,dc=eu #CHANGE TO YOUR OWN LDAP
2. RDN: cn
6. connection URL: YOUR_LDAP_SERVER_ADDRESS
3. UUID: uid
7. authentication : simple
4. User object classes: inetOrgPerson, organizationalPerson
8. bind DN: cn=admin,dc=eosc-life,dc=eu # CHANGE TO YOUR OWN ADMIN DN
5. user DN:ou=users,dc=eosc-life,dc=eu #CHANGE TO YOUR OWN LDAP
9. bind credential: YOUR_LDAP_BIND_PASSWORD
6. connection URL: YOUR_LDAP_SERVER_ADDRESS
10. custom user ldap filter: (objectClass=posixAccount)
7. authentication : simple
11. search scope: subtree
8. bind DN: cn=admin,dc=eosc-life,dc=eu # CHANGE TO YOUR OWN ADMIN DN
12. use truststore spi: only for ldaps
9. bind credential: YOUR_LDAP_BIND_PASSWORD
13. connection pooling: on
10. custom user ldap filter: (objectClass=posixAccount)