Skip to content

Commit 5a62ae5

Browse files
authored
Add setting to disable BASIC authentication (#8586)
Closes #8561.
1 parent 280f4be commit 5a62ae5

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

custom/conf/app.ini.sample

+5-1
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@ ALLOW_ONLY_EXTERNAL_REGISTRATION = false
436436
REQUIRE_SIGNIN_VIEW = false
437437
; Mail notification
438438
ENABLE_NOTIFY_MAIL = false
439+
; This setting enables gitea to be signed in with HTTP BASIC Authentication using the user's password
440+
; If you set this to false you will not be able to access the tokens endpoints on the API with your password
441+
; Please note that setting this to false will not disable OAuth Basic or Basic authentication using a token
442+
ENABLE_BASIC_AUTHENTICATION = true
439443
; More detail: https://github.com/gogits/gogs/issues/165
440444
ENABLE_REVERSE_PROXY_AUTHENTICATION = false
441445
ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = false
@@ -866,6 +870,6 @@ TOKEN =
866870
QUEUE_TYPE = channel
867871
; Task queue length, available only when `QUEUE_TYPE` is `channel`.
868872
QUEUE_LENGTH = 1000
869-
; Task queue connction string, available only when `QUEUE_TYPE` is `redis`.
873+
; Task queue connction string, available only when `QUEUE_TYPE` is `redis`.
870874
; If there is a password of redis, use `addrs=127.0.0.1:6379 password=123 db=0`.
871875
QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+4
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
265265
- `REQUIRE_SIGNIN_VIEW`: **false**: Enable this to force users to log in to view any page.
266266
- `ENABLE_NOTIFY_MAIL`: **false**: Enable this to send e-mail to watchers of a repository when
267267
something happens, like creating issues. Requires `Mailer` to be enabled.
268+
- `ENABLE_BASIC_AUTHENTICATION`: **true**: Disable this to disallow authenticaton using HTTP
269+
BASIC and the user's password. Please note if you disable this you will not be able to access the
270+
tokens API endpoints using a password. Further, this only disables BASIC authentication using the
271+
password - not tokens or OAuth Basic.
268272
- `ENABLE_REVERSE_PROXY_AUTHENTICATION`: **false**: Enable this to allow reverse proxy authentication.
269273
- `ENABLE_REVERSE_PROXY_AUTO_REGISTRATION`: **false**: Enable this to allow auto-registration
270274
for reverse authentication.

modules/auth/auth.go

+3
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool)
224224
}
225225

226226
if u == nil {
227+
if !setting.Service.EnableBasicAuth {
228+
return nil, false
229+
}
227230
u, err = models.UserSignIn(uname, passwd)
228231
if err != nil {
229232
if !models.IsErrUserNotExist(err) {

modules/setting/service.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var Service struct {
2323
ShowRegistrationButton bool
2424
RequireSignInView bool
2525
EnableNotifyMail bool
26+
EnableBasicAuth bool
2627
EnableReverseProxyAuth bool
2728
EnableReverseProxyAutoRegister bool
2829
EnableReverseProxyEmail bool
@@ -60,6 +61,7 @@ func newService() {
6061
Service.EmailDomainWhitelist = sec.Key("EMAIL_DOMAIN_WHITELIST").Strings(",")
6162
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
6263
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
64+
Service.EnableBasicAuth = sec.Key("ENABLE_BASIC_AUTHENTICATION").MustBool(true)
6365
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
6466
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
6567
Service.EnableReverseProxyEmail = sec.Key("ENABLE_REVERSE_PROXY_EMAIL").MustBool()

0 commit comments

Comments
 (0)