web.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. )
  23. type loginPage struct {
  24. CurrentURL string
  25. Version string
  26. Error string
  27. CSRFToken string
  28. StaticURL string
  29. AltLoginURL string
  30. ForgotPwdURL string
  31. OpenIDLoginURL string
  32. ExtraCSS []CustomCSS
  33. }
  34. type twoFactorPage struct {
  35. CurrentURL string
  36. Version string
  37. Error string
  38. CSRFToken string
  39. StaticURL string
  40. RecoveryURL string
  41. ExtraCSS []CustomCSS
  42. }
  43. type forgotPwdPage struct {
  44. CurrentURL string
  45. Error string
  46. CSRFToken string
  47. StaticURL string
  48. Title string
  49. ExtraCSS []CustomCSS
  50. }
  51. type resetPwdPage struct {
  52. CurrentURL string
  53. Error string
  54. CSRFToken string
  55. StaticURL string
  56. Title string
  57. ExtraCSS []CustomCSS
  58. }
  59. func getSliceFromDelimitedValues(values, delimiter string) []string {
  60. result := []string{}
  61. for _, v := range strings.Split(values, delimiter) {
  62. cleaned := strings.TrimSpace(v)
  63. if cleaned != "" {
  64. result = append(result, cleaned)
  65. }
  66. }
  67. return result
  68. }