Keyrock doesn't recognize super-admin user

62 views Asked by At

I'm making a project for a course in uni. I'm running a keyrock container in docker and I use a .http file to make direct request for X-Auth-Token with the default super-admin user. The request:

###get X-Auth-Token directly in keyrock
GET http://localhost:3005/v1/auth/tokens
Content-Type: application/json

{"email":"[email protected]","password":"1234"}

From what I understand in the documentation this super-user is initialized by the keyrock service by default and the request is the same as keyrock documentation, except if I made some error. This is what it returns:

HTTP/1.1 401 Unauthorized
Cache-Control: no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0
Content-Type: application/json; charset=utf-8
Content-Length: 83
ETag: W/"53-HM/hhsSfxoQsxV7mUMAoJqvJdJ0"
Date: Sat, 14 Jan 2023 11:02:23 GMT
Connection: close

{
  "error": {
    "message": "Invalid email or password",
    "code": 401,
    "title": "Unauthorized"
  }
}

I will also show the docker-compose file for clarity:

version: "3.8"

networks:
  idm_network:
    driver: bridge

#project images
services:
#  projectapp:
#     build: ./projectapp
#     networks:
#       - idm_network
#     depends_on:
#       - keyrock
#     ports:
#       - "8080:8080"
#     expose:
#        - 8080    

  mysql:
      build: ./mysql         
      command:
      - "--default-authentication-plugin=mysql_native_password"
      networks:
        - idm_network
      volumes:
        - mysqlVolume:/var/lib/mysql
      environment:
        - MYSQL_ROOT_PASSWORD=idm
        - MYSQL_ROOT_HOST=%  
        - MYSQL_USER=root
        - MYSQL_DATABASE=idm      

  keyrock:
    image: fiware/idm:7.6.0  
    networks:
        - idm_network
    depends_on:
        - mysql
    ports:
      - "3005:3000"
      - "443:443"
    environment:
        - IDM_DB_HOST=mysql
        - IDM_HOST=http://localhost:3005
        - IDM_PORT=3005
        - IDM_DB_USER=root
        - IDM_ADMIN_USER=admin
        - [email protected]
        - IDM_ADMIN_PASS=1234


.
.
.
  
#project volumes
volumes:
  mysqlVolume:
  mongoOrionVolume:
  mongoDataVolume:

Don't all these environment variables in keyrock mean that is the default admin user's credentials?

Thank you for your time.

1

There are 1 answers

0
Νικόλας Καστρινάκης On

Ok, so apparently the admin user is not added by default you have to create it. In the step-by-step guide: https://github.com/FIWARE/tutorials.Identity-Management/tree/NGSI-v2 in the mysql-data there is a .sql backup file that should be added in the initialization process.

Inside this file in line 710 or so you can add as many users as you want and there you can add your default super admin user with any credentials you want. I know it worked, because in the container CLI I can now see the idm database, the tables and the user I created in the 'user' table.

Unfortunately, my request still doesn't work, I'm not sure why, but this should work for most people I assume.