web.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. }
  32. type twoFactorPage struct {
  33. CurrentURL string
  34. Version string
  35. Error string
  36. CSRFToken string
  37. StaticURL string
  38. RecoveryURL string
  39. }
  40. type forgotPwdPage struct {
  41. CurrentURL string
  42. Error string
  43. CSRFToken string
  44. StaticURL string
  45. Title string
  46. }
  47. type resetPwdPage struct {
  48. CurrentURL string
  49. Error string
  50. CSRFToken string
  51. StaticURL string
  52. Title string
  53. }
  54. func getSliceFromDelimitedValues(values, delimiter string) []string {
  55. result := []string{}
  56. for _, v := range strings.Split(values, delimiter) {
  57. cleaned := strings.TrimSpace(v)
  58. if cleaned != "" {
  59. result = append(result, cleaned)
  60. }
  61. }
  62. return result
  63. }