Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Suggestion: The default username and password of the docker version are obtained from env #1390

Closed
byl0561 opened this issue May 16, 2024 · 3 comments

Comments

@byl0561
Copy link

byl0561 commented May 16, 2024

Since the current default administrator account and password are hard-coded, login authorization is useless. It is recommended to obtain it from docker env instead.

Relevant code:

package ai.chat2db.server.domain.api.enums;

import ai.chat2db.server.tools.base.enums.BaseEnum;
import lombok.Getter;

/**

  • role code

  • @author Jiaju Zhuang
    /
    @Getter
    public enum RoleCodeEnum implements BaseEnum {
    /
    *

    • DESKTOP
      */
      DESKTOP("DESKTOP", 1L, "_desktop_default_user_name", "_desktop_default_user_name"),

    /**

    • ADMIN
      */
      ADMIN("ADMIN", 2L, "chat2db", "chat2db"),

    /**

    • USER
      */
      USER("USER", null, null, null),

    ;
    final String description;
    final Long defaultUserId;
    final String userName;
    final String password;

    RoleCodeEnum(String description, Long defaultUserId, String userName, String password) {
    this.description = description;
    this.defaultUserId = defaultUserId;
    this.userName = userName;
    this.password = password;
    }

    @OverRide
    public String getCode() {
    return this.name();
    }
    }

@byl0561
Copy link
Author

byl0561 commented May 16, 2024

you can make this:
ADMIN("ADMIN", 2L, "chat2db", "chat2db"),
Change to this:
ADMIN("ADMIN", 2L, System.getenv().getOrDefault("ADMIN_NAME", "chat2db"), System.getenv().getOrDefault("ADMIN_PASS", "chat2db")),

@miahemu miahemu changed the title 建议: docker版本的默认用户名和密码从env中获取 Suggestion: The default username and password of the docker version are obtained from env May 18, 2024
@miahemu
Copy link
Collaborator

miahemu commented Jul 4, 2024

OK, accepted, thank you!

miahemu added a commit to miahemu/Chat2DB that referenced this issue Jul 4, 2024
miahemu added a commit that referenced this issue Jul 5, 2024
@byl0561
Copy link
Author

byl0561 commented Jul 25, 2024

Verified. Thank you.

@byl0561 byl0561 closed this as completed Jul 25, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants