mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-27 20:25:41 +00:00
feat: add option to disable resources server
This commit is contained in:
@@ -255,7 +255,8 @@ func (app *BootstrapApp) Setup() error {
|
||||
}, apiRouter, authService)
|
||||
|
||||
resourcesController := controller.NewResourcesController(controller.ResourcesControllerConfig{
|
||||
ResourcesDir: app.config.ResourcesDir,
|
||||
ResourcesDir: app.config.ResourcesDir,
|
||||
ResourcesDisabled: app.config.DisableResources,
|
||||
}, mainRouter)
|
||||
|
||||
healthController := controller.NewHealthController(apiRouter)
|
||||
|
||||
@@ -40,6 +40,7 @@ type Config struct {
|
||||
DatabasePath string `mapstructure:"database-path" validate:"required"`
|
||||
TrustedProxies string `mapstructure:"trusted-proxies"`
|
||||
DisableAnalytics bool `mapstructure:"disable-analytics"`
|
||||
DisableResources bool `mapstructure:"disable-resources"`
|
||||
}
|
||||
|
||||
// OAuth/OIDC config
|
||||
|
||||
@@ -7,7 +7,8 @@ import (
|
||||
)
|
||||
|
||||
type ResourcesControllerConfig struct {
|
||||
ResourcesDir string
|
||||
ResourcesDir string
|
||||
ResourcesDisabled bool
|
||||
}
|
||||
|
||||
type ResourcesController struct {
|
||||
@@ -38,5 +39,12 @@ func (controller *ResourcesController) resourcesHandler(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
if controller.config.ResourcesDisabled {
|
||||
c.JSON(403, gin.H{
|
||||
"status": 403,
|
||||
"message": "Resources are disabled",
|
||||
})
|
||||
return
|
||||
}
|
||||
controller.fileServer.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user