[Feature Request] Add creation OAuth APP from cli and with ENVIRONMENT VARS #4215

Open
opened 2025-11-02 05:42:41 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @toni-moreno on GitHub (Oct 31, 2019).

Description

We have to automate the Gitea + Drone Install , but , we can not automate the setup process because of gitea needs to setup OAuth APP from WebUI As described in (https://docs.drone.io/installation/providers/gitea/) )

On Docker environments the best way is with environment vars (not sure how to do it ) but really useful on this use case.

Originally created by @toni-moreno on GitHub (Oct 31, 2019). ## Description We have to automate the Gitea + Drone Install , but , we can not automate the setup process because of gitea needs to setup OAuth APP from WebUI As described in (https://docs.drone.io/installation/providers/gitea/) ) On Docker environments the best way is with environment vars (not sure how to do it ) but really useful on this use case.
GiteaMirror added the type/proposal label 2025-11-02 05:42:41 -06:00
Author
Owner

@zeripath commented on GitHub (Nov 1, 2019):

Would my pr #7287 be sufficient for this?

@zeripath commented on GitHub (Nov 1, 2019): Would my pr #7287 be sufficient for this?
Author
Owner

@techknowlogick commented on GitHub (Nov 1, 2019):

@zeripath I dont think so because that would just configure app.ini settings. This request is to setup an OAuth2 provider using env vars. I would prefer to add it via CLI, just like we did for other OAuth app/LDAP management.

@techknowlogick commented on GitHub (Nov 1, 2019): @zeripath I dont think so because that would just configure app.ini settings. This request is to setup an [OAuth2 provider](https://docs.gitea.io/en-us/oauth2-provider/) using env vars. I would prefer to add it via CLI, just like we did for other OAuth app/LDAP management.
Author
Owner

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

OAuth2 Provider is enabled by default. I think he means create an OAuth2 application via commandline and return ClientID and ClientSecret with suitable console format.

@lunny commented on GitHub (Nov 2, 2019): OAuth2 Provider is enabled by default. I think he means create an OAuth2 application via commandline and return ClientID and ClientSecret with suitable console format.
Author
Owner

@lukasmrtvy commented on GitHub (Nov 16, 2019):

Not sure if API/CLI commands are enough in this case. ( Unattended install of gitea and drone - integrated ), but its definetly must have feature of course for future generic usage.

Something like GITEA_OAUTH2_PROVIDER_ID, GITEA_OAUTH2_PROVIDER_SECRET and GITEA_OAUTH2_PROVIDER_REPLYURL vars ( for precreating oauth application ) should be enough to deploy both applications at the same time ( integration at deploy time ).
Of course GITEA_USERNAME and GITEA_PASSWORD vars would be also superb to implement.

Other options like docker exec -it gitea gitea admin oauth2 app create... or curl -X POST http://gitea/api/v1/user/application '{"id": ...}', that needs output parsing and use it as input for another container ( drone in this case ) are not best way how to do it.

@lukasmrtvy commented on GitHub (Nov 16, 2019): Not sure if API/CLI commands are enough in this case. ( Unattended install of gitea and drone - integrated ), but its definetly *must have* feature of course for future generic usage. Something like `GITEA_OAUTH2_PROVIDER_ID`, `GITEA_OAUTH2_PROVIDER_SECRET` and `GITEA_OAUTH2_PROVIDER_REPLYURL` vars ( for precreating oauth application ) should be enough to deploy both applications at the same time ( integration at deploy time ). Of course `GITEA_USERNAME` and `GITEA_PASSWORD` vars would be also superb to implement. Other options like `docker exec -it gitea gitea admin oauth2 app create...` or `curl -X POST http://gitea/api/v1/user/application '{"id": ...}'`, that needs output parsing and use it as input for another container ( drone in this case ) are not best way how to do it.
Author
Owner

@lukasmrtvy commented on GitHub (Dec 9, 2019):

Proposal https://github.com/go-gitea/gitea/issues/9210

@lukasmrtvy commented on GitHub (Dec 9, 2019): Proposal https://github.com/go-gitea/gitea/issues/9210
Author
Owner

@danielchg commented on GitHub (Feb 20, 2020):

is there any update on this issue?

@danielchg commented on GitHub (Feb 20, 2020): is there any update on this issue?
Author
Owner

@everflux commented on GitHub (Apr 23, 2022):

Is this available through the CLI as well? (For unattended setup - it is important that the clientid/secret can be supplied/specified instead of randomly generated. )

@everflux commented on GitHub (Apr 23, 2022): Is this available through the CLI as well? (For unattended setup - it is important that the clientid/secret can be supplied/specified instead of randomly generated. )
Author
Owner

@gramakri commented on GitHub (Dec 20, 2022):

Per https://docs.gitea.io/en-us/command-line/#admin , gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE is an example

@gramakri commented on GitHub (Dec 20, 2022): Per https://docs.gitea.io/en-us/command-line/#admin , ` gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE ` is an example
Author
Owner

@lunny commented on GitHub (Dec 20, 2022):

I think this has been resolved.

@lunny commented on GitHub (Dec 20, 2022): I think this has been resolved.
Author
Owner

@maxkratz commented on GitHub (Dec 31, 2022):

Per https://docs.gitea.io/en-us/command-line/#admin , gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE is an example

This command can be used to add a new authentication source, but OP wants to add an oauth2 application. Can this be done with the CLI?

@maxkratz commented on GitHub (Dec 31, 2022): > Per https://docs.gitea.io/en-us/command-line/#admin , `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE` is an example This command can be used to add a new authentication source, but OP wants to add an oauth2 application. Can this be done with the CLI?
Author
Owner

@lunny commented on GitHub (Dec 31, 2022):

Per https://docs.gitea.io/en-us/command-line/#admin , gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE is an example

This command can be used to add a new authentication source, but OP wants to add an oauth2 application. Can this be done with the CLI?

Not yet.

@lunny commented on GitHub (Dec 31, 2022): > > Per https://docs.gitea.io/en-us/command-line/#admin , `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE` is an example > > This command can be used to add a new authentication source, but OP wants to add an oauth2 application. Can this be done with the CLI? Not yet.
Author
Owner

@maxkratz commented on GitHub (Dec 31, 2022):

Not yet.

Thank you for your fast response. In this case, I suggest to re-open this issue.

@maxkratz commented on GitHub (Dec 31, 2022): > Not yet. Thank you for your fast response. In this case, I suggest to re-open this issue.
Author
Owner

@everflux commented on GitHub (Mar 7, 2024):

It would be really great, if this could be addressed as manual setup takes a lot of time and is error prone when setting up multiple instances for trainings or demos. (So an ENV approach is preferred to CLI)

@everflux commented on GitHub (Mar 7, 2024): It would be really great, if this could be addressed as manual setup takes a lot of time and is error prone when setting up multiple instances for trainings or demos. (So an ENV approach is preferred to CLI)
Author
Owner

@wrenix commented on GitHub (Jan 9, 2025):

The UI generates for us Client ID and Client secret. Is it possible to force set it?

@wrenix commented on GitHub (Jan 9, 2025): The UI generates for us Client ID and Client secret. Is it possible to force set it?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4215