Feaure requests: unattended installation, user creation, app creation, sso, ldap integration #4423

Closed
opened 2025-11-02 05:50:17 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @lukasmrtvy on GitHub (Nov 29, 2019).

Hello,
Here is my proposal to solve:

https://github.com/go-gitea/gitea/blob/master/docker/root/etc/s6/gitea/setup

if ! gitea migration --test; 
then
  printf 'do migration' 
  gitea migrate
fi

if [ -z $GITEA_USERNAME && -z $GITEA_PASSWORD && -z $GITEA_EMAIL ]; 
   printf 'user creation initiated' 
   if ! gitea admin get-user $GITEA_USERNAME; then
     printf 'user not found, creating new one'
     gitea admin create-user -u 
   else
     printf 'user found, modificating email and password'
     gitea admin edit-user $GITEA_USERNAME -p $GITEA_PASSWORD -m $GITEA_EMAIL
   fi
fi

if [ -z $GITEA_OAUTH2_PROVIDER_ID && $GITEA_OAUTH2_PROVIDER_SECRET ];
then
   printf 'oauth app creation initiated'
   if ! gitea admin get-app $GITEA_OAUTH2_PROVIDER_ID; then
     printf 'app not found, creating new one'
     gitea admin add-app $GITEA_OAUTH2_PROVIDER_ID -p $GITEA_OAUTH2_PROVIDER_SECRET
   else
     printf 'app found , modificating secret'
     gitea admin edit-app $GITEA_OAUTH2_PROVIDER_ID -p $GITEA_OAUTH2_PROVIDER_SECRET
   fi
fi

To do this, its needed to integrate new gitea commands:

  • gitea migration --test -> test if migration is done ( no need to use postgresql-client, mariadb-client, etc to check db tables are populated/migrated )
  • gitea admin get-user -> get gitea user ( name, password, email )
  • gitea admin edit-user -> edit gitea user ( password, email )
  • gitea admin add-app -> add oauth application ( id secret )
  • gitea admin edit-app -> edit oauth application ( secret )

P.S. modification commands are not necesary, its just for fully idempotent initialization of new instance. ( new gitea instance with old gitea db ). Even gitea admin auth update-oauth and gitea admin auth update-ldap exists...

Environment variables:

  • GITEA_USERNAME
  • GITEA_PASSWORD
  • GITEA_EMAIL
  • GITEA_OAUTH2_PROVIDER_ID
  • GITEA_OAUTH2_PROVIDER_SECRET

Something similar should be used also for oauth and ldap authentication.
There are already commands for it:

  • gitea admin auth add-oauth
  • gitea admin auth add-ldap

Would be nice to have fully integrated gitea at deploy time.

Any other ideas @lunny ?
Thanks

Originally created by @lukasmrtvy on GitHub (Nov 29, 2019). Hello, Here is my proposal to solve: - unattended installation https://github.com/go-gitea/gitea/issues/2324 - default admin user creation https://discourse.gitea.io/t/i-cannot-programmatically-setup-users-in-a-docker-container/289/8 - default oauth app creation https://github.com/go-gitea/gitea/issues/8764 - default sso integration ( not solved here ) https://github.com/go-gitea/gitea/blob/master/docker/root/etc/s6/gitea/setup ```bash if ! gitea migration --test; then printf 'do migration' gitea migrate fi if [ -z $GITEA_USERNAME && -z $GITEA_PASSWORD && -z $GITEA_EMAIL ]; printf 'user creation initiated' if ! gitea admin get-user $GITEA_USERNAME; then printf 'user not found, creating new one' gitea admin create-user -u else printf 'user found, modificating email and password' gitea admin edit-user $GITEA_USERNAME -p $GITEA_PASSWORD -m $GITEA_EMAIL fi fi if [ -z $GITEA_OAUTH2_PROVIDER_ID && $GITEA_OAUTH2_PROVIDER_SECRET ]; then printf 'oauth app creation initiated' if ! gitea admin get-app $GITEA_OAUTH2_PROVIDER_ID; then printf 'app not found, creating new one' gitea admin add-app $GITEA_OAUTH2_PROVIDER_ID -p $GITEA_OAUTH2_PROVIDER_SECRET else printf 'app found , modificating secret' gitea admin edit-app $GITEA_OAUTH2_PROVIDER_ID -p $GITEA_OAUTH2_PROVIDER_SECRET fi fi ``` To do this, its needed to integrate new gitea commands: - `gitea migration --test` -> test if migration is done ( no need to use postgresql-client, mariadb-client, etc to check db tables are populated/migrated ) - `gitea admin get-user` -> get gitea user ( name, password, email ) - `gitea admin edit-user` -> edit gitea user ( password, email ) - `gitea admin add-app` -> add oauth application ( id secret ) - `gitea admin edit-app` -> edit oauth application ( secret ) P.S. modification commands are not necesary, its just for fully idempotent initialization of new instance. ( new gitea instance with old gitea db ). Even `gitea admin auth update-oauth` and `gitea admin auth update-ldap` exists... Environment variables: - `GITEA_USERNAME ` - `GITEA_PASSWORD` - `GITEA_EMAIL` - `GITEA_OAUTH2_PROVIDER_ID` - `GITEA_OAUTH2_PROVIDER_SECRET` Something similar should be used also for oauth and ldap authentication. There are already commands for it: - `gitea admin auth add-oauth` - `gitea admin auth add-ldap` Would be nice to have fully integrated gitea at deploy time. Any other ideas @lunny ? Thanks
GiteaMirror added the type/proposal label 2025-11-02 05:50:17 -06:00
Author
Owner

@lunny commented on GitHub (Nov 30, 2019):

It's interesting. We need some new commands.

@lunny commented on GitHub (Nov 30, 2019): It's interesting. We need some new commands.
Author
Owner

@kapsh commented on GitHub (Jul 14, 2021):

+1 for this feature, dockerised setup really could use default admin account.

@kapsh commented on GitHub (Jul 14, 2021): +1 for this feature, dockerised setup really could use default admin account.
Author
Owner

@techknowlogick commented on GitHub (Jul 16, 2021):

In 1.14.x this is a lot more straightforward, see https://discourse.gitea.io/t/unattended-gitea-installation-from-the-cli/3373/14 for details.

@techknowlogick commented on GitHub (Jul 16, 2021): In 1.14.x this is a lot more straightforward, see https://discourse.gitea.io/t/unattended-gitea-installation-from-the-cli/3373/14 for details.
Author
Owner

@kapsh commented on GitHub (Jul 17, 2021):

@techknowlogick this works, thanks for the hint.

@kapsh commented on GitHub (Jul 17, 2021): @techknowlogick this works, thanks for the hint.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4423