Search code examples
dockerdocker-composejbosskeycloak

Keycloak- Invalid config for has Algorithm: Password hashing provider not found


I am running keycloak on docker, and I want to import a realm, previously exported. But I get the error: Error during startup: org.keycloak.models.ModelException: Invalid config for hashAlgorithm: Password hashing provider not found I read that I needed to copy jbcrypt.jar to the container, in standalone/deployments folder. I then created a Dockerfile with the, so I could copy jbcrypt. Please how can I provide a password hashing provider for bcrypt?.

Dockerfile:

FROM jboss/keycloak:latest

ARG KEYCLOAK_HOME=/opt/jboss/keycloak
RUN curl -L https://github.com/leroyguillaume/keycloak-bcrypt/releases/download/1.5.0/keycloak-bcrypt-1.5.0.jar > $KEYCLOAK_HOME/standalone/deployments/keycloak-bcrypt-1.5.0.jar
RUN curl -L https://repo1.maven.org/maven2/org/mindrot/jbcrypt/0.4/jbcrypt-0.4.jar > $KEYCLOAK_HOME/standalone/deployments/jbcrypt-0.4.jar

RUN cd $KEYCLOAK_HOME/standalone/deployments/ && ls
RUN /opt/jboss/keycloak/bin/jboss-cli.sh --command="module add --name=org.mindrot.jbcrypt --resources=$KEYCLOAK_HOME/standalone/deployments/jbcrypt-0.4.jar"
RUN /opt/jboss/keycloak/bin/jboss-cli.sh --command="module add --name=org.mindrot.keycloakbcrypt --resources=$KEYCLOAK_HOME/standalone/deployments/keycloak-bcrypt-1.5.0.jar"

docker-compose.yml

version: '3'

volumes:
  postgres_data:
    driver: local

services:
  ncbs_core_keycloak_postgres:
    image: postgres:latest
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: keycloak
      POSTGRES_USER: keycloak
      POSTGRES_PASSWORD: password
    restart: always
  ncbs_core_keycloak:
#    image: jboss/keycloak:latest
    build: .
    environment:
      DB_VENDOR: POSTGRES
      DB_ADDR: ncbs_core_keycloak_postgres
      DB_DATABASE: keycloak
      DB_USER: keycloak
      DB_SCHEMA: public
      DB_PASSWORD: password
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: admin
      KEYCLOAK_IMPORT: ./imports/realm-export.json
      # Uncomment the line below if you want to specify JDBC parameters. The parameter below is just an example, and it shouldn't be used in production without knowledge. It is highly recommended that you read the PostgreSQL JDBC driver documentation in order to use it.
      #JDBC_PARAMS: "ssl=true"
    command:
      - "-b 0.0.0.0"
      - "-Dkeycloak.migration.action=import"
      - "-Dkeycloak.migration.provider=singleFile"
      - "-Dkeycloak.migration.file=/opt/jboss/keycloak/imports/realm-export.json"
      - "-Dkeycloak.migration.strategy=OVERWRITE_EXISTING"
    volumes:
      - ./imports:/opt/jboss/keycloak/imports
    ports:
      - 8080:8080
    depends_on:
      - ncbs_core_keycloak_postgres


Solution

  • I've used volume in docker-compose to get it working without restart Download the lib from GitHub and mount as a volume like below:

    volumes:
    - ./keycloak-bcrypt-1.5.0.jar:/opt/jboss/keycloak/standalone/deployments/keycloak-bcrypt-1.5.0.jar