简体   繁体   English

Keyrock 无法识别超级管理员用户

[英]Keyrock doesn't recognize super-admin user

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.我在 docker 中运行一个 keyrock 容器,我使用 .http 文件向默认超级管理员用户直接请求 X-Auth-Token。 The request:要求:

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

{"email":"admin@test.com","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.根据我在文档中的理解,这个超级用户默认由 keyrock 服务初始化,并且请求与 keyrock 文档相同,除非我犯了一些错误。 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:为了清楚起见,我还将显示 docker-compose 文件:

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
        - IDM_ADMIN_EMAIL=admin@test.com
        - 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? keyrock 中的所有这些环境变量不都意味着这是默认管理员用户的凭据吗?

Thank you for your time.感谢您的时间。

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.在分步指南中: https://github.com/FIWARE/tutorials.Identity-Management/tree/NGSI-v2在mysql-data中有一个.sql备份文件,应该在初始化过程中添加.

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.在此文件中的第 710 行左右,您可以根据需要添加任意数量的用户,并且可以在其中添加具有您想要的任何凭据的默认超级管理员用户。 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.我知道它有效,因为在容器 CLI 中,我现在可以看到 idm 数据库、表和我在“用户”表中创建的用户。

Unfortunately, my request still doesn't work, I'm not sure why, but this should work for most people I assume.不幸的是,我的请求仍然不起作用,我不确定为什么,但这应该适用于我认为的大多数人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM