Automatically create admin user on install


Gogs version: 0.9.20
System: Docker
Database: sqlite3

Is there a default admin user or any way to set up an admin user automatically on install? I have INSTALL_LOCK = true and have tried creating an admin user through REST api but have not had success.

# not working gives 500 Internal Server Error
curl -v -X POST -H "Content-Type: application/json" -d "{
    \"source_id\": 1,
    \"login_name\": \"go\",
    \"username\": \"go\",
    \"password\": \"Password1\",
    \"email\": \"\"
  }" "http://localhost:3000/api/v1/admin/users"


I remember there was default admin account in earlier version. Looks like default admin feature got removed in recent versions.

I would suggest have a button option on the Web GUI to delete the default admin account once config is finished.


If you check what the element names are in the /install form, you may be able to POST the entries to complete the installation. I can look further into it this evening, but it would be similar to your curl operation but generating a payload to POST to http://localhost:3000/install


The form you’re looking for is auth.InstallForm in modules/auth/user_form.go:14


@tcarrio generating a payload to POST to http://localhost:3000/install worked. Thanks!


How did you get this to work exactly. Doesn’t work for me…


Here’s how I got it going:

curl -X POST 'http://localhost:3000/install' \

This is the content of the payload file:

$ cat