web.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package httpd
  2. import (
  3. "strings"
  4. )
  5. const (
  6. pageMFATitle = "Two-factor authentication"
  7. page400Title = "Bad request"
  8. page403Title = "Forbidden"
  9. page404Title = "Not found"
  10. page404Body = "The page you are looking for does not exist."
  11. page500Title = "Internal Server Error"
  12. page500Body = "The server is unable to fulfill your request."
  13. webDateTimeFormat = "2006-01-02 15:04:05" // YYYY-MM-DD HH:MM:SS
  14. redactedSecret = "[**redacted**]"
  15. csrfFormToken = "_form_token"
  16. csrfHeaderToken = "X-CSRF-TOKEN"
  17. templateCommonDir = "common"
  18. templateTwoFactor = "twofactor.html"
  19. templateTwoFactorRecovery = "twofactor-recovery.html"
  20. templateForgotPassword = "forgot-password.html"
  21. templateResetPassword = "reset-password.html"
  22. templateCommonCSS = "sftpgo.css"
  23. )
  24. type loginPage struct {
  25. CurrentURL string
  26. Version string
  27. Error string
  28. CSRFToken string
  29. StaticURL string
  30. AltLoginURL string
  31. AltLoginName string
  32. ForgotPwdURL string
  33. OpenIDLoginURL string
  34. Branding UIBranding
  35. }
  36. type twoFactorPage struct {
  37. CurrentURL string
  38. Version string
  39. Error string
  40. CSRFToken string
  41. StaticURL string
  42. RecoveryURL string
  43. Branding UIBranding
  44. }
  45. type forgotPwdPage struct {
  46. CurrentURL string
  47. Error string
  48. CSRFToken string
  49. StaticURL string
  50. Title string
  51. Branding UIBranding
  52. }
  53. type resetPwdPage struct {
  54. CurrentURL string
  55. Error string
  56. CSRFToken string
  57. StaticURL string
  58. Title string
  59. Branding UIBranding
  60. }
  61. func getSliceFromDelimitedValues(values, delimiter string) []string {
  62. result := []string{}
  63. for _, v := range strings.Split(values, delimiter) {
  64. cleaned := strings.TrimSpace(v)
  65. if cleaned != "" {
  66. result = append(result, cleaned)
  67. }
  68. }
  69. return result
  70. }