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.
You will need a server ready with proper DNS name for the public facing portal, before configuring keyloak.
**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)
2. install nginx
```text
apt-get update -y & apt-get install -y nginx
```
3\. Obtain SSL certificates from IT or Letsencrypt
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
docker pull jboss/keycloak
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
* Default Scopes: openid email profile
* Permission tab: enabled
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.
This article will be of help on creating keylcoak extensions https://andrebiegel.github.io/projects/2021/08/28/keycloak-extensions.html
8\. Create your own login them, and copy it into keycloak container (https://www.keycloak.org/docs/latest/server_development/)
9\. restart keycloak container
10.login into the keycloak container, check /etc/hosts. it should contain the correct LDAP server IP
**Configuration via Keycloak admin interface**
[Refer to Keycload documentations](https://www.keycloak.org/docs/latest/server_admin/)
The below steps are examples used in BAND, if your client names are different, change accordingly.
1. create realm name
1. endpoints: OpenID Endpoint Configuration
2. Login tabs: all OFF
3. Themes: name_of_your_theme
2. create following clients.
1. eosc-client
1. set to ON for "Enabled, Standard Flow Enabled, Direct Access Grants Enabled", leave the rest OFF
2. Valid redirect URIs:
1. https://band.embl.de/*
2. https://band.embl.de/eosc/*
3. https://band.embl.de/eosc/api/linked
4. create Token Mappers
* email -> User Property, Token claim: email, Property: email
* openid ->RealmProperty, Token claim: openid, Realm role prefix: openid
* family name ->User Property, Token claim: family\_name, Property: lastName
* full name -> User's full name
* given name ->User Property, Token claim:given\_name, Property: firstName
2. resource
1. set to ON for "Enabled, Standard Flow Enabled, Direct Access Grants Enabled, Service Accounts Enabled, authorization Enabled", leave the rest OFF
2. valid redirect URI
1. https://band.embl.de/*
2. https://band.embl.de/kc/api/*
3. https://band.embl.de/resource
4. create Token Mappers (same as eosc-client)
3. service account roles. eosc and user role are created via Roles page
1. eosc
2. user
3. offline\_access
4. uma\_authorization
4. Scope: full scope allowed
3. User Federation:
1. these are settings connect to ldap server
1. username LDAP attribute: uid
2. RDN: cn
3. UUID: uid
4. User object classes: inetOrgPerson, organizationalPerson
5. user DN:ou=users,dc=eosc-life,dc=eu #CHANGE TO YOUR OWN LDAP
6. connection URL: YOUR_LDAP_SERVER_ADDRESS
7. authentication : simple
8. bind DN: cn=admin,dc=eosc-life,dc=eu # CHANGE TO YOUR OWN ADMIN DN
9. bind credential: YOUR_LDAP_BIND_PASSWORD
10. custom user ldap filter: (objectClass=posixAccount)