web.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright (C) 2019-2022 Nicola Murino
  2. //
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU Affero General Public License as published
  5. // by the Free Software Foundation, version 3.
  6. //
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU Affero General Public License for more details.
  11. //
  12. // You should have received a copy of the GNU Affero General Public License
  13. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. package httpd
  15. import (
  16. "strings"
  17. )
  18. const (
  19. pageMFATitle = "Two-factor authentication"
  20. page400Title = "Bad request"
  21. page403Title = "Forbidden"
  22. page404Title = "Not found"
  23. page404Body = "The page you are looking for does not exist."
  24. page500Title = "Internal Server Error"
  25. page500Body = "The server is unable to fulfill your request."
  26. webDateTimeFormat = "2006-01-02 15:04:05" // YYYY-MM-DD HH:MM:SS
  27. redactedSecret = "[**redacted**]"
  28. csrfFormToken = "_form_token"
  29. csrfHeaderToken = "X-CSRF-TOKEN"
  30. templateCommonDir = "common"
  31. templateTwoFactor = "twofactor.html"
  32. templateTwoFactorRecovery = "twofactor-recovery.html"
  33. templateForgotPassword = "forgot-password.html"
  34. templateResetPassword = "reset-password.html"
  35. templateCommonCSS = "sftpgo.css"
  36. )
  37. type loginPage struct {
  38. CurrentURL string
  39. Version string
  40. Error string
  41. CSRFToken string
  42. StaticURL string
  43. AltLoginURL string
  44. AltLoginName string
  45. ForgotPwdURL string
  46. OpenIDLoginURL string
  47. Branding UIBranding
  48. FormDisabled bool
  49. }
  50. type twoFactorPage struct {
  51. CurrentURL string
  52. Version string
  53. Error string
  54. CSRFToken string
  55. StaticURL string
  56. RecoveryURL string
  57. Branding UIBranding
  58. }
  59. type forgotPwdPage struct {
  60. CurrentURL string
  61. Error string
  62. CSRFToken string
  63. StaticURL string
  64. Title string
  65. Branding UIBranding
  66. }
  67. type resetPwdPage struct {
  68. CurrentURL string
  69. Error string
  70. CSRFToken string
  71. StaticURL string
  72. Title string
  73. Branding UIBranding
  74. }
  75. func getSliceFromDelimitedValues(values, delimiter string) []string {
  76. result := []string{}
  77. for _, v := range strings.Split(values, delimiter) {
  78. cleaned := strings.TrimSpace(v)
  79. if cleaned != "" {
  80. result = append(result, cleaned)
  81. }
  82. }
  83. return result
  84. }