mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-12-08 09:16:35 +00:00
feat: add option to disable ui warnings
This commit is contained in:
@@ -236,6 +236,7 @@ func (app *BootstrapApp) Setup() error {
|
||||
ForgotPasswordMessage: app.config.ForgotPasswordMessage,
|
||||
BackgroundImage: app.config.BackgroundImage,
|
||||
OAuthAutoRedirect: app.config.OAuthAutoRedirect,
|
||||
DisableUIWarnings: app.config.DisableUIWarnings,
|
||||
}, apiRouter)
|
||||
|
||||
oauthController := controller.NewOAuthController(controller.OAuthControllerConfig{
|
||||
|
||||
@@ -41,6 +41,7 @@ type Config struct {
|
||||
TrustedProxies string `mapstructure:"trusted-proxies"`
|
||||
DisableAnalytics bool `mapstructure:"disable-analytics"`
|
||||
DisableResources bool `mapstructure:"disable-resources"`
|
||||
DisableUIWarnings bool `mapstructure:"disable-ui-warnings"`
|
||||
SocketPath string `mapstructure:"socket-path"`
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ type AppContextResponse struct {
|
||||
ForgotPasswordMessage string `json:"forgotPasswordMessage"`
|
||||
BackgroundImage string `json:"backgroundImage"`
|
||||
OAuthAutoRedirect string `json:"oauthAutoRedirect"`
|
||||
DisableUIWarnings bool `json:"disableUiWarnings"`
|
||||
}
|
||||
|
||||
type Provider struct {
|
||||
@@ -48,6 +49,7 @@ type ContextControllerConfig struct {
|
||||
ForgotPasswordMessage string
|
||||
BackgroundImage string
|
||||
OAuthAutoRedirect string
|
||||
DisableUIWarnings bool
|
||||
}
|
||||
|
||||
type ContextController struct {
|
||||
@@ -56,6 +58,10 @@ type ContextController struct {
|
||||
}
|
||||
|
||||
func NewContextController(config ContextControllerConfig, router *gin.RouterGroup) *ContextController {
|
||||
if config.DisableUIWarnings {
|
||||
log.Warn().Msg("UI warnings are disabled. This may expose users to security risks. Proceed with caution.")
|
||||
}
|
||||
|
||||
return &ContextController{
|
||||
config: config,
|
||||
router: router,
|
||||
@@ -117,5 +123,6 @@ func (controller *ContextController) appContextHandler(c *gin.Context) {
|
||||
ForgotPasswordMessage: controller.config.ForgotPasswordMessage,
|
||||
BackgroundImage: controller.config.BackgroundImage,
|
||||
OAuthAutoRedirect: controller.config.OAuthAutoRedirect,
|
||||
DisableUIWarnings: controller.config.DisableUIWarnings,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ var controllerCfg = controller.ContextControllerConfig{
|
||||
ForgotPasswordMessage: "Contact admin to reset your password.",
|
||||
BackgroundImage: "/assets/bg.jpg",
|
||||
OAuthAutoRedirect: "google",
|
||||
DisableUIWarnings: false,
|
||||
}
|
||||
|
||||
var userContext = config.UserContext{
|
||||
@@ -75,6 +76,7 @@ func TestAppContextHandler(t *testing.T) {
|
||||
ForgotPasswordMessage: controllerCfg.ForgotPasswordMessage,
|
||||
BackgroundImage: controllerCfg.BackgroundImage,
|
||||
OAuthAutoRedirect: controllerCfg.OAuthAutoRedirect,
|
||||
DisableUIWarnings: controllerCfg.DisableUIWarnings,
|
||||
}
|
||||
|
||||
router, recorder := setupContextController(nil)
|
||||
@@ -102,6 +104,7 @@ func TestUserContextHandler(t *testing.T) {
|
||||
Provider: userContext.Provider,
|
||||
OAuth: userContext.OAuth,
|
||||
TotpPending: userContext.TotpPending,
|
||||
OAuthName: userContext.OAuthName,
|
||||
}
|
||||
|
||||
// Test with context
|
||||
|
||||
Reference in New Issue
Block a user