Keycloak

Les urls

  • Url géneral: https://auth.ppsfleet.navy
  • Pour gérer ses infos: https://auth.ppsfleet.navy/auth/realms/Ppsfleet/account/
  • Pour l'interface admin de ppsfleet: https://auth.ppsfleet.navy/auth/admin/Ppsfleet/console/

Installation

Keycloak est lancé avec podman par l'utilisateur keycloak:

podman run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e PROXY_ADDRESS_FORWARDING=true quay.io/keycloak/keycloak:11.0.3

Gérer le service

sudo -u keycloak podman start/stop f9a1cdb967b5

Ne pas supprimer le container sans qu'une backup ait été effectué !

Todo: le relier à mysql

Backup

$ podman commit <id>
$ podman tag <id_image> keycloak-<date>
$ podman run -it -v /srv/keycloak/backup:/backup:rw --entrypoint=sh keycloak-<date>
$ HOSTNAME=alshain.ppsfleet.navy
$ /opt/jboss/keycloak/bin/standalone.sh -Dkeycloak.migration.action=export -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.realmName=Ppsfleet -Dkeycloak.migration.usersExportStrategy=REALM_FILE -Dkeycloak.migration.file="/backup/"$(date +%Y%m%d)".json"

Les services:

I - Bookstack

  • https://github.com/elexis/elexis-environment/blob/master/docker/ee-util/assets/stage_ee_start_setup/keycloak/bookstack-saml.json
  • https://github.com/BookStackApp/BookStack/issues/1157#issuecomment-585804153
AUTH_METHOD=saml2

# Set the display name to be shown on the login button.
# (Login with <name>)
SAML2_NAME=ppsfleet

# Name of the attribute which provides the user's email address

SAML2_EMAIL_ATTRIBUTE=email
SAML2_EXTERNAL_ID_ATTRIBUTE=username
SAML2_DISPLAY_NAME_ATTRIBUTES=firstName|lastName


# Enable SAML group sync.
SAML2_USER_TO_GROUPS=true

# Set the attribute from which BookStack will read groups names from.
SAML2_GROUP_ATTRIBUTE=Role

# Removed user from roles that don't match SAML groups upon login.
SAML2_REMOVE_FROM_GROUPS=true

# Name of the attribute(s) to use for the user's display name
# Can have mulitple attributes listed, separated with a '|' in which 
# case those values will be joined with a space.
# Example: SAML2_DISPLAY_NAME_ATTRIBUTES=firstName|lastName
# Defaults to the ID value if not found.
#SAML2_DISPLAY_NAME_ATTRIBUTES=username

# Identity Provider entityID URL
SAML2_IDP_ENTITYID=https://auth.ppsfleet.navy/auth/realms/Ppsfleet/protocol/saml/descriptor

II - Nextcloud

https://auth.ppsfleet.navy/auth/realms/Ppsfleet

Si il y a une erreur du type: "account not provisioned" c'est durement un problème de certificat.

Le certificat se trouve dans keycloak: Realm settings > keys > algorithm RS256 > Cetificate

Il faut le mettre dans les paramètre de nextcloud: SSO and SAML authentication > show optional Identity Provider settings > dernier champ

Config:

Identifier: https://auth.ppsfleet.navy/auth/realms/Ppsfleet

Url target: https://auth.ppsfleet.navy/auth/realms/Ppsfleet/protocol/saml