web.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. templateTwoFactor = "twofactor.html"
  18. templateTwoFactorRecovery = "twofactor-recovery.html"
  19. )
  20. type loginPage struct {
  21. CurrentURL string
  22. Version string
  23. Error string
  24. CSRFToken string
  25. StaticURL string
  26. AltLoginURL string
  27. }
  28. type twoFactorPage struct {
  29. CurrentURL string
  30. Version string
  31. Error string
  32. CSRFToken string
  33. StaticURL string
  34. RecoveryURL string
  35. }
  36. func getSliceFromDelimitedValues(values, delimiter string) []string {
  37. result := []string{}
  38. for _, v := range strings.Split(values, delimiter) {
  39. cleaned := strings.TrimSpace(v)
  40. if cleaned != "" {
  41. result = append(result, cleaned)
  42. }
  43. }
  44. return result
  45. }