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