All articles

Wanna use Keycloak to sign in to your Passbolt instance? Here's the way to go

10 min. read

Max Zanardo

Max Zanardo

1 February, 2024

Use Keycloak to sign in to your Passbolt instance

Important notice

  • Your Passbolt instance is up and running
  • You have the necessary accesses to change the configuration files (like an SSH access through a terminal)
  • While docker is not the only way to setup a passbolt instance, we will use a docker compose file to simplify the demonstration. Please go to https://help.passbolt.com/hosting/install for more information.

Spinning up a Keycloak instance

version: '3'

volumes:
  postgres_data:
      driver: local
  keycloak_data:

services:
  postgres:
      image: postgres
      volumes:
        - postgres_data:/var/lib/postgresql/data
      environment:
        POSTGRES_DB: keycloak
        POSTGRES_USER: keycloak
        POSTGRES_PASSWORD: password
  keycloak:
      image: quay.io/keycloak/keycloak:latest
      environment:
        KEYCLOAK_ADMIN: admin
        KEYCLOAK_ADMIN_PASSWORD: admin123
        KEYCLOAK_LOGLEVEL: INFO
        ROOT_LOGLEVEL: INFO
        KC_HTTPS_CERTIFICATE_FILE: /opt/keycloak/conf/server.crt.pem
        KC_HTTPS_CERTIFICATE_KEY_FILE: /opt/keycloak/conf/server.key.pem
      ports:
        - "8081:8080"
        - "8787:8787"
        - "8443:8443"
      command:
        - start-dev
        - --features admin-fine-grained-authz
      volumes:
        - keycloak_data:/opt/keycloak/data
        - ./domain.crt:/opt/keycloak/conf/server.crt.pem
        - ./domain.key:/opt/keycloak/conf/server.key.pem
  • A file to configure the SSL (ssl_gen_config.txt)
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
subjectAltName = @alt_names
[alt_names]
DNS.1 = keycloak.passbolt.local
  • A script file that will generates all the files you need createSslKeys.sh (you can change what you need in it of course or if you want to do a very quick test, you can use it as-is)
#!/bin/sh

openssl req -x509 -sha256 -days 2000 -newkey rsa:2048 -subj "/C=LU/ST=Luxembourg/L=Esch-Sur-Alzette/O=Local CA/OU=Local CA/CN=My RootCA" -nodes -keyout rootCA.key -out rootCA.crt

openssl req -newkey rsa:2048  -subj "/C=LU/ST=Luxembourg/L=Esch-Sur-Alzette/O=Keycloak local/OU=Keycloak local test/CN=keycloak.passbolt.local/" -nodes -addext "subjectAltName = DNS:keycloak.passbolt.local" -keyout domain.key -out domain.csr

openssl x509 -req -CA rootCA.crt -CAkey rootCA.key -in domain.csr -out domain.crt -days 365 -CAcreateserial -extfile ssl_gen_config.txt
./createSslKeys.sh
docker-compose -f docker-compose.yaml up

Configuring Keycloak

The realm and a client

Fig 1. The Keycloak administration console home page
  1. Click on top left corner drop-down and then click on Create Realm
Fig 2. Keycloak logged-in home page with realm list drop-down
Fig 3. Keycloak realm creation form
  1. Click on Create. Your new realm is now available
  2. Check that are currently on your new realm (on top left corner or use the drop-down to switch to the new realm)
  3. Go on `Clients` and create a new one
    1. Step 1 (General Settings): set the following 
      1. `Client type`: “OpenId Connect”
      2. `Client-id`: pick what you prefer (we will use `passbolt-client-id`)
      3. Name and Description: they are not required, they, however will help you to manage your Keycloak instance.
Fig 4. Keycloak client creation form (step 1)
  1. Step 2 (Capability config): pick the following
    1. Client authentication
    2. Authorisation
    3. Authentication flow: `standard flow`
Fig 5. Keycloak client creation form (step 2)
  1. Step 3 (Login Settings): we won’t do anything in this example. Click on Save

Creating a user in your Keycloak instance

Fig 6. Keycloak user creation form (step 2)
Fig 7. Keycloak user credentials tab

Configuring the Passbolt instance

Configuring the server where Passbolt is served

Domain name resolution
127.0.0.1  keycloak.passbolt.local
ping  keycloak.passbolt.local
SSL Certificate configuration
# The certificate file has to be placed in `/usr/share/ca-certificates` folder or subfolders to be detected 
mv rootCA.crt /usr/share/ca-certificates/rootCA.crt

# Update the list of trusted certificates
sudo dpkg-reconfigure ca-certificates
curl -s -o /dev/null -v https://keycloak.passbolt.local:8443
  • the rootCA.crt and the domain.crt share the same CN value
  • the domain.crt is set for a domain that is not the one use (you might have a typo in it)
  • the rootCA.crt is actually not trusted on your server
  • the server responding to the curl request is not the expected one

Passbolt configuration file modification

Updating the Passbolt admin settings

  1. Sign in to Passbolt with an administrator account
  2. Go on the administration workspace
  3. Select Single Sign On in the menu on the left
  4. A list of SSO provider appears choose Open ID
Fig 8. Passbolt SSO admin settings with all provide cards
  1. In the form, copy the Redirect URL field content and use it in your Keycloak realm configuration as an authorised URL to redirect to (check the next section to see how)
  2. Fulfill the form with the corresponding configuration (see below an example)
Fig 9. Passbolt OpenID settings form
  1. Ask for saving the settings to do a sign-in dry-run and ensure the configuration is working
  2. After a successful sign in against your SSO provider, click on the save button and you're good to go
  3. [Optional] As an extra step, you can sign out from Passbolt after it's configured and see the Sign in with OpenId button and test it to confirm it's working
  • URL: https://keycloak.passbolt.local:8443/realm/Passbolt
  • OpenId configuration path: /.well-known/openid-configuration
  • Scope: openid email profile
  • Client Id: passbolt-client-id
  • Client secret: the client secret from your keycloak instance (see in a next section how to find it)
  • both your Passbolt server and Keycloak server being able to communicate together through HTTPS
  • Your Passbolt administration Settings are set and working.

Continue reading

FOSDEM 2024 Retrospective

4 min. read

FOSDEM 2024 Retrospective

At FOSDEM 2024, the Passbolt team not only connected with the open-source community but also shared insights on the future of authentication technologies through engaging talks. Join us in exploring the event's highlights and our team's key takeaways.

Phibasara Wanniang

Phibasara Wanniang

9 February, 2024

Passbolt Helm Chart Now Supports PostgreSQL

3 min. read

Passbolt Helm Chart Now Supports PostgreSQL

Our Helm Chart now supports PostgreSQL!

Passbolt team

Passbolt team

29 January, 2024

Flag of European UnionMade in Europe. Privacy by default.