mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 10:39:38 -05:00
Allow authentication to be set in app.ini / migrate all authentication to app.ini #62
Closed
opened 2025-11-02 03:06:38 -06:00 by GiteaMirror
·
34 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1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3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#62
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stevenroose on GitHub (Nov 16, 2016).
From @stevenroose on May 28, 2016 0:38
We are trying to package Gogs to work with YunoHost, but this issue affects anyone packaging Gogs automatic installation.
We want to enable LDAP authentication during installation, but when automating the installation, it is hard to inject the authentication config into the SQL table because the table is only initialized on the first run.
Since the
app.iniis the place we can manipulate Gogs configuration for automated installation, ideally authentication configuration should be here too.Since I have no idea of how authentication is implemented in general, I don't know if there are arguments why authentication should be in SQL at all. If there are no fundamental arguments, I would be willing to try and migrate authentication config to
app.ini, making sure compatibility is maintained for upgrading users.Copied from original issue: gogits/gogs#3142
@stevenroose commented on GitHub (Nov 16, 2016):
From @Unknwon on July 2, 2016 15:45
Hi... actually I'm not quite understand what you're trying to describe... but set auth info in
app.iniwould be acceptable, it seems a dirty workaround instead of a solution.@stevenroose commented on GitHub (Nov 16, 2016):
It just seems to me that authentication settings are part of the installation configuration rather than something to do at runtime. So it should be put in
app.iniinstead of the database.Many packaged versions of Gogs that are specifically made for a certain software distribution will want to automatically integrate Gogs with the authentication scheme they use during the installation period. That is currently impossible because the authentication section from Gogs can only be accessed while it is running through the web interface or through the underlying SQL DB.
So what I propose is a new
app.inisection f.e.[authentication]or[ldap]where the required LDAP parameters can be provided.Examples of apps using config files for auth (I think the ones that don't are actually very rare) are: Owncloud, Seafile, Roundcube, Ampache, Baikal and actually all of the ones that I came across when packaging apps for YunoHost.
@stevenroose commented on GitHub (Nov 16, 2016):
From @Unknwon on July 7, 2016 23:53
Gogs supports theoretically unlimited authentication sources, that's why config in file is not possible.
@stevenroose commented on GitHub (Nov 16, 2016):
From @jerrykan on July 8, 2016 12:48
Having to configure the authentication sources in the DB is an impediment to being able to deploy gogs using configuration management tools. I imagine it would be possible to implement any number of authentication sources using the following sort of scheme in the
app.inithe
backendvalue in the[auth]section defines the priority of the authentication sources that are enabled and are references to the[auth_*]sections which contain the configuration for each authentication source.It may require a little more processing of the
app.inifile to load the configuration settings, but it should be possible.@stevenroose commented on GitHub (Nov 16, 2016):
From @Unknwon on July 8, 2016 13:6
@jerrykan good point, but I think we probably should just make a new file named
auth_sources.iniorauth_sources.conf?@stevenroose commented on GitHub (Nov 16, 2016):
From @jerrykan on July 9, 2016 14:2
@Unknwon my personal preference would be to keep everything in
app.iniso there is only one file to configure/manage, but I don't see any major issues if it were to be implemented in another config file.@stevenroose commented on GitHub (Nov 16, 2016):
From @Unknwon on July 9, 2016 14:15
app.iniis more about site configuration, but authentication sources are site data in my opinion.@stevenroose commented on GitHub (Nov 16, 2016):
From @jerrykan on July 10, 2016 13:19
I don't see configuring authentication backends as being any different to configuring the database or mail servers. It is site specific, generally configured during initial setup, and rarely changes. So I wouldn't really consider the it data.
@stevenroose commented on GitHub (Nov 16, 2016):
@Unknwon Can you point me to where auth configuration is located? Perhaps I can try and implement the migration myself.
@stevenroose commented on GitHub (Nov 16, 2016):
From @Unknwon on August 3, 2016 4:23
@stevenroose
login_sourcetable.@lunny commented on GitHub (Nov 17, 2016):
I don't think that storeing LDAP configuration on
app.iniis a better idea. But I think It could be done via Gitea APIs. We can provide LDAP configuration API so that you can add it just call the APIs.@strk commented on GitHub (Nov 17, 2016):
It does make sense to me for site configuration to be in a configuration file rather than in the database, I've actually found myself in the troubling situation of having to migrate a database table to fully replicate a configuration (rather than just copying the custom/ directory over)
@lunny commented on GitHub (Nov 21, 2016):
Of course, we could add some subcommand to
gitea admincommand to finish the work.@stevenroose commented on GitHub (Nov 21, 2016):
Setting up authentication is part of the installation. Right now if you
only want LDAP users, there's a catch-22 because you need to login to
add an authentication method but you cannot login because LDAP is not
configured yet. The same holds with any other type except the default one.
I've setup quite a number of self-hosted web services and all of them
store auth config statically.
On 21-11-16 02:54, Lunny Xiao wrote:
@strk commented on GitHub (Nov 21, 2016):
I also think the authentication mechanism should be refactored to be explicit about which auth method is in use from the web UI. It should also help adding more complex auth methods (like OAuth/OpenID)
@lunny commented on GitHub (Nov 22, 2016):
Or we can add LDAP or SMTP config on installation page? And this is not very difficult, since we have already authentication page on admin panel.
@jerrykan commented on GitHub (Nov 22, 2016):
For most of the systems we manage that have to use an "install page" to install/configure a system is a real pain. Every configuration management tool available makes it easy to mange plain text configuration files, hence why it is so desirable for configuration to be done in config files instead of in the DB. Even for advanced users who don't use config management tools being able to edit a file and restart the service is much easier than running some SQL on a DB or make and API request to make configuration changes. With configuration files you also don't end up in a situation where authentication breaks and you can't log into the system to make the necessary configuration changes to fix things.
Having "install pages" are useful to help new users get something up and going, but forcing advanced users to use them is an anti-feature, when all they want to do is copy a pre-made configuration file into place and be done with the configuration side of things.
@lunny commented on GitHub (Nov 22, 2016):
So that, I think maybe https://github.com/go-gitea/gitea/issues/209 will resolve this.
@stevenroose commented on GitHub (Nov 22, 2016):
@jerrykan I totally agree. Install pages are a pain in the ass for platforms like YunoHost that want to ship a preconfigured version.
@strk About explicitly mentioning the auth method, I'm not sure. It makes sense for OpenID, but not for the different username/password types. Username/password methods with different DB types (because LDAP is just another DB to store user information) should all use the regular username/password fields. While I agree for the more exotic methods, an explicit button/whatever is good.
@ptman commented on GitHub (Mar 13, 2017):
I agree that all (non-per-user) configuration should be possible to make via a config file.
@stevenroose but for a quick work-around, how tied is gitea/xorm to the schema version (apparently stored in the version table)? Can you just create an SQL script that would setup the bare minimum schema and values for configuring LDAP and then let the first run upgrade the schema to whatever is the current version?
@phtan commented on GitHub (Apr 15, 2018):
For what it's worth, [at]Unknwon claims he has implemented something in Gogs, on 12th of April 2018 (GMT +8). Here's the link: https://github.com/gogits/gogs/issues/3142#issuecomment-380815756
@khaledkbadr commented on GitHub (Jun 26, 2018):
So is this feature frozen, declined or will be implemented in the future?
@strk commented on GitHub (Jun 27, 2018):
I think it's waiting for someone (you?) to implement it
@stevenroose commented on GitHub (Jul 30, 2018):
@strk, did you have the chance to take a look at unknwon's supposed implementation?
@yobert commented on GitHub (Sep 5, 2018):
I worked around this with a post-configure script that I run after the app starts up:
post-configure.txt
@yobert commented on GitHub (Sep 5, 2018):
^ That example is for adding PAM authentication
@strk commented on GitHub (Mar 29, 2019):
@stevenroose I didn't have a chance to look at Googs implementation but that comment is really interesting.
@lunny commented on GitHub (Mar 29, 2019):
Since
gitea admin authcommand line could manage auth source, I think this issue maybe not necessary.@DblK commented on GitHub (May 28, 2019):
According to the docs (https://docs.gitea.io/en-us/command-line/) there is only a command for oauth.
Is there any for ldap (or other sources)?
Is there anybody who are being able to fully automate install of gitea without any login first?
@zeripath commented on GitHub (May 28, 2019):
There's a PR to add ldap configuration but it's sort of languishing because no-one has had a chance to look at it. (#6681)
@6543 commented on GitHub (Sep 7, 2020):
I think this issue can be closed now ...
@jerrykan commented on GitHub (Sep 8, 2020):
@6543 Does the
git admin authcommand store the configuration in theapp.inifile or in the database? if it is just updating the configuration in the database then it isn't solving the use-case outlined in this issue.@6543 commented on GitHub (Sep 8, 2020):
no auth is stored in db
@techknowlogick commented on GitHub (Dec 9, 2020):
closing as via CLI is how we've chosen to go, and this method works for many different packagings of Gitea, even our Helm-chart uses the CLI and I've seen customized docker images use entrypoints with the CLI.