harbor登录切换
MorningFish Lv6

harbor 在设置完 ldap 登录之后,ldap 会出现响应超时情况,所以想改回数据库模式,但是在页面上不能再设置为其他认证方式。

通过阅读 harbor 的源码,发现其中的限制为以下代码:

1
2
3
4
5
6
7
8
9
10
11
// AuthModeCanBeModified determines whether auth mode can be
// modified or not. Auth mode can modified when there is only admin
// user in database.
func AuthModeCanBeModified() (bool, error) {
c, err := GetOrmer().QueryTable(&models.User{}).Count()
if err != nil {
return false, err
}
// admin and anonymous
return c == 2, nil
}

从中可以看出来,只有在数据库registry->harbor_user 中的数量为2时,才可以修改,所以需要进入psql中,将多余的用户删除掉,只保留anonymousadmin

1
DELETE FROM harbor_user where id>2;

执行DELETE语句时可能会遇到外键不允许删除,需要把registry->project中的owner_id 设置为admin1

  • Post title:harbor登录切换
  • Post author:MorningFish
  • Create time:2020-11-19 12:03:48
  • Post link:https://chazyu.com/2020/11/19/harbor/login/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments