diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2022-04-04 17:46:55 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-04 17:46:55 +1000 | 
| commit | a2eb0316c89507d80f6448777a21627a4cedbafe (patch) | |
| tree | 345bf54af2262cc48d9de6280a773e7f3984b745 /internal/server/server.go | |
| parent | b8280dfed6b62b570865a1933d6b4b9461dfbc71 (diff) | |
feat(web): password reset custom url (#3111)
This allows providing a custom URL for password resets. If provided the disable_reset_password option is ignored, the password reset API is disabled, and the button provided in the UI to reset the password redirects users to the configured endpoint.
Closes #1934, Closes #2854
Co-authored-by: you1996 <youssri@flyweight.tech>
Diffstat (limited to 'internal/server/server.go')
| -rw-r--r-- | internal/server/server.go | 11 | 
1 files changed, 7 insertions, 4 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index 6c5b19ce1..b52c87001 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -24,6 +24,8 @@ func registerRoutes(configuration schema.Configuration, providers middlewares.Pr  	rememberMe := strconv.FormatBool(configuration.Session.RememberMeDuration != schema.RememberMeDisabled)  	resetPassword := strconv.FormatBool(!configuration.AuthenticationBackend.DisableResetPassword) +	resetPasswordCustomURL := configuration.AuthenticationBackend.PasswordReset.CustomURL.String() +  	duoSelfEnrollment := f  	if configuration.DuoAPI != nil {  		duoSelfEnrollment = strconv.FormatBool(configuration.DuoAPI.EnableSelfEnrollment) @@ -34,9 +36,9 @@ func registerRoutes(configuration schema.Configuration, providers middlewares.Pr  	https := configuration.Server.TLS.Key != "" && configuration.Server.TLS.Certificate != "" -	serveIndexHandler := ServeTemplatedFile(embeddedAssets, indexFile, configuration.Server.AssetPath, duoSelfEnrollment, rememberMe, resetPassword, configuration.Session.Name, configuration.Theme, https) -	serveSwaggerHandler := ServeTemplatedFile(swaggerAssets, indexFile, configuration.Server.AssetPath, duoSelfEnrollment, rememberMe, resetPassword, configuration.Session.Name, configuration.Theme, https) -	serveSwaggerAPIHandler := ServeTemplatedFile(swaggerAssets, apiFile, configuration.Server.AssetPath, duoSelfEnrollment, rememberMe, resetPassword, configuration.Session.Name, configuration.Theme, https) +	serveIndexHandler := ServeTemplatedFile(embeddedAssets, indexFile, configuration.Server.AssetPath, duoSelfEnrollment, rememberMe, resetPassword, resetPasswordCustomURL, configuration.Session.Name, configuration.Theme, https) +	serveSwaggerHandler := ServeTemplatedFile(swaggerAssets, indexFile, configuration.Server.AssetPath, duoSelfEnrollment, rememberMe, resetPassword, resetPasswordCustomURL, configuration.Session.Name, configuration.Theme, https) +	serveSwaggerAPIHandler := ServeTemplatedFile(swaggerAssets, apiFile, configuration.Server.AssetPath, duoSelfEnrollment, rememberMe, resetPassword, resetPasswordCustomURL, configuration.Session.Name, configuration.Theme, https)  	r := router.New()  	r.GET("/", autheliaMiddleware(serveIndexHandler)) @@ -77,7 +79,8 @@ func registerRoutes(configuration schema.Configuration, providers middlewares.Pr  	r.POST("/api/logout", autheliaMiddleware(handlers.LogoutPost))  	// Only register endpoints if forgot password is not disabled. -	if !configuration.AuthenticationBackend.DisableResetPassword { +	if !configuration.AuthenticationBackend.DisableResetPassword && +		configuration.AuthenticationBackend.PasswordReset.CustomURL.String() == "" {  		// Password reset related endpoints.  		r.POST("/api/reset-password/identity/start", autheliaMiddleware(  			handlers.ResetPasswordIdentityStart))  | 
