2022-07-17 18:16:00 +00:00
|
|
|
// Copyright (C) 2019-2022 Nicola Murino
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published
|
|
|
|
// by the Free Software Foundation, version 3.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2019-10-07 16:19:01 +00:00
|
|
|
package httpd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2021-01-25 20:31:33 +00:00
|
|
|
const (
|
2021-09-04 10:11:04 +00:00
|
|
|
pageMFATitle = "Two-factor authentication"
|
|
|
|
page400Title = "Bad request"
|
|
|
|
page403Title = "Forbidden"
|
|
|
|
page404Title = "Not found"
|
|
|
|
page404Body = "The page you are looking for does not exist."
|
|
|
|
page500Title = "Internal Server Error"
|
|
|
|
page500Body = "The server is unable to fulfill your request."
|
|
|
|
webDateTimeFormat = "2006-01-02 15:04:05" // YYYY-MM-DD HH:MM:SS
|
|
|
|
redactedSecret = "[**redacted**]"
|
|
|
|
csrfFormToken = "_form_token"
|
|
|
|
csrfHeaderToken = "X-CSRF-TOKEN"
|
2021-11-13 12:25:43 +00:00
|
|
|
templateCommonDir = "common"
|
2021-09-04 10:11:04 +00:00
|
|
|
templateTwoFactor = "twofactor.html"
|
|
|
|
templateTwoFactorRecovery = "twofactor-recovery.html"
|
2021-11-13 12:25:43 +00:00
|
|
|
templateForgotPassword = "forgot-password.html"
|
|
|
|
templateResetPassword = "reset-password.html"
|
2022-05-14 09:54:55 +00:00
|
|
|
templateCommonCSS = "sftpgo.css"
|
2021-01-25 20:31:33 +00:00
|
|
|
)
|
|
|
|
|
2021-01-17 21:29:08 +00:00
|
|
|
type loginPage struct {
|
2022-02-13 13:30:20 +00:00
|
|
|
CurrentURL string
|
|
|
|
Version string
|
|
|
|
Error string
|
|
|
|
CSRFToken string
|
|
|
|
StaticURL string
|
|
|
|
AltLoginURL string
|
2022-05-15 05:30:36 +00:00
|
|
|
AltLoginName string
|
2022-02-13 13:30:20 +00:00
|
|
|
ForgotPwdURL string
|
|
|
|
OpenIDLoginURL string
|
2022-05-13 17:40:52 +00:00
|
|
|
Branding UIBranding
|
2021-01-17 21:29:08 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 10:11:04 +00:00
|
|
|
type twoFactorPage struct {
|
|
|
|
CurrentURL string
|
|
|
|
Version string
|
|
|
|
Error string
|
|
|
|
CSRFToken string
|
|
|
|
StaticURL string
|
|
|
|
RecoveryURL string
|
2022-05-13 17:40:52 +00:00
|
|
|
Branding UIBranding
|
2021-09-04 10:11:04 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 12:25:43 +00:00
|
|
|
type forgotPwdPage struct {
|
|
|
|
CurrentURL string
|
|
|
|
Error string
|
|
|
|
CSRFToken string
|
|
|
|
StaticURL string
|
|
|
|
Title string
|
2022-05-13 17:40:52 +00:00
|
|
|
Branding UIBranding
|
2021-11-13 12:25:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type resetPwdPage struct {
|
|
|
|
CurrentURL string
|
|
|
|
Error string
|
|
|
|
CSRFToken string
|
|
|
|
StaticURL string
|
|
|
|
Title string
|
2022-05-13 17:40:52 +00:00
|
|
|
Branding UIBranding
|
2021-11-13 12:25:43 +00:00
|
|
|
}
|
|
|
|
|
2019-12-30 17:37:50 +00:00
|
|
|
func getSliceFromDelimitedValues(values, delimiter string) []string {
|
|
|
|
result := []string{}
|
|
|
|
for _, v := range strings.Split(values, delimiter) {
|
|
|
|
cleaned := strings.TrimSpace(v)
|
2021-01-25 20:31:33 +00:00
|
|
|
if cleaned != "" {
|
2019-12-30 17:37:50 +00:00
|
|
|
result = append(result, cleaned)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|