helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

initial admin/password to random secret

Open tekkisse opened this issue 3 years ago • 4 comments

be good to be able to set the initial admin user and password (not password??). The core product does not seem to do this - do you know if his is possible.

Your chart could then be extended to enable a secrets file t generate and hold the pasword/username

tekkisse avatar Jul 05 '21 22:07 tekkisse

I assume you are talking about sftpgo, right?

If so, it's already possible to load initial data, including admin users.

In values, you need to set:

env:
  SFTPGO_LOADDATA_FROM: "/etc/sftpgo/loaddata/data.json"
  SFTPGO_LOADDATA_MODE: "0"


volumes:
  - name: load-data
    secret:
      secretName: "${load_data}"

volumeMounts:
  - name: load-data
    mountPath: /etc/sftpgo/loaddata

Then you need to create a configmap/secret that you can mount as a file with the following (or similar) content:

{
    "users": [
       // LIST OF INITIAL USERS
    ],
    "folders": [],
    "admins": [
        {
            "id": 1,
            "status": 1,
            "username": "admin",
            "password": "BCRYP_HASH",
            "email": "",
            "permissions": [
                "*"
            ],
            "filters": {}
        }
    ],
    "version": 8
}

Read the official configuration for more.

sagikazarmark avatar Jul 06 '21 11:07 sagikazarmark

@sagikazarmark I just set

config:
  data_provider:
    create_default_admin: true

in values.ymal can I got a default admin user?

fangzi0813 avatar Aug 19 '21 09:08 fangzi0813

@sagikazarmark I tried your solution, and I don't understand why I still can't connect.

In logs I see my new admin is set:

{"level":"debug","time":"2021-10-19T21:29:31.511","sender":"httpd","message":"adding new admin: {ID:1 Status:1 Username:issif Password:[**redacted**] Email: Permissions:[*] Filters:{AllowList:[]} Description: AdditionalInfo:}, dump file: \"/etc/sftpgo/loaddata/data.json\", error: <nil>"}

But I get an invalid credentials, whatever I enter (I used bcrypt hash for password).

In logs I have:

{"level":"warn","time":"2021-10-19T21:50:08.591","sender":"dataprovider_sqlite","message":"error authenticating user \"issif\": not found: sql: no rows in result set"}
{"level":"debug","time":"2021-10-19T21:50:08.591","sender":"connection_failed","client_ip":"10.96.218.255","username":"","login_type":"password","protocol":"HTTP","error":"not found: sql: no rows in result set"}

edit:

I tried to create a simple user, and it worked, it's only broken for the admins.

Thanks

Issif avatar Oct 19 '21 21:10 Issif

😅 I got it. I didn't noticed the connection URL are not same between admin and client, I tried to connect on client page as admin.

Issif avatar Oct 20 '21 15:10 Issif