mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-17 19:00:39 +01:00
Add option to deny anonymous (i.e. unauthorized) access
This commit is contained in:
14
src/main/scala/app/AnonymousAccessController.scala
Normal file
14
src/main/scala/app/AnonymousAccessController.scala
Normal file
@@ -0,0 +1,14 @@
|
||||
package app
|
||||
|
||||
class AnonymousAccessController extends AnonymousAccessControllerBase
|
||||
|
||||
trait AnonymousAccessControllerBase extends ControllerBase {
|
||||
get(!context.settings.allowAnonymousAccess, context.loginAccount.isEmpty) {
|
||||
if(!context.currentPath.startsWith("/assets") && !context.currentPath.startsWith("/signin") &&
|
||||
!context.currentPath.startsWith("/register")) {
|
||||
Unauthorized()
|
||||
} else {
|
||||
pass()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
||||
"baseUrl" -> trim(label("Base URL", optional(text()))),
|
||||
"information" -> trim(label("Information", optional(text()))),
|
||||
"allowAccountRegistration" -> trim(label("Account registration", boolean())),
|
||||
"allowAnonymousAccess" -> trim(label("Anonymous access", boolean())),
|
||||
"gravatar" -> trim(label("Gravatar", boolean())),
|
||||
"notification" -> trim(label("Notification", boolean())),
|
||||
"ssh" -> trim(label("SSH access", boolean())),
|
||||
|
||||
Reference in New Issue
Block a user