mirror of
https://github.com/portainer/portainer.git
synced 2025-07-26 00:39:41 +02:00
feat(security): shutdown instance after 5minutes if no admin account created (#2500)
* feat(security): skip admin check if --no-auth * fix(security): change error message
This commit is contained in:
parent
acce5e0023
commit
101bb41587
1 changed files with 19 additions and 0 deletions
|
@ -468,6 +468,21 @@ func initJobService(dockerClientFactory *docker.ClientFactory) portainer.JobServ
|
||||||
return docker.NewJobService(dockerClientFactory)
|
return docker.NewJobService(dockerClientFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func terminateIfNoAdminCreated(userService portainer.UserService) {
|
||||||
|
timer1 := time.NewTimer(5 * time.Minute)
|
||||||
|
<-timer1.C
|
||||||
|
|
||||||
|
users, err := userService.UsersByRole(portainer.AdministratorRole)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(users) == 0 {
|
||||||
|
log.Fatal("No administrator account was created after 5 min. Shutting down the Portainer instance for security reasons.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flags := initCLI()
|
flags := initCLI()
|
||||||
|
|
||||||
|
@ -586,6 +601,10 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !*flags.NoAuth {
|
||||||
|
go terminateIfNoAdminCreated(store.UserService)
|
||||||
|
}
|
||||||
|
|
||||||
var server portainer.Server = &http.Server{
|
var server portainer.Server = &http.Server{
|
||||||
Status: applicationStatus,
|
Status: applicationStatus,
|
||||||
BindAddress: *flags.Addr,
|
BindAddress: *flags.Addr,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue