2020-06-05 07:50:04 +02:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
2020-06-11 13:22:24 +02:00
|
|
|
"errors"
|
2020-06-05 07:50:04 +02:00
|
|
|
"fmt"
|
2020-09-18 13:26:28 +02:00
|
|
|
"html/template"
|
|
|
|
"net/http"
|
|
|
|
"path"
|
2020-07-20 10:00:29 +02:00
|
|
|
|
2020-12-02 17:00:04 +01:00
|
|
|
"github.com/caos/logging"
|
|
|
|
"github.com/gorilla/csrf"
|
|
|
|
"golang.org/x/text/language"
|
|
|
|
|
2020-08-31 08:49:35 +02:00
|
|
|
http_mw "github.com/caos/zitadel/internal/api/http/middleware"
|
2020-06-05 07:50:04 +02:00
|
|
|
"github.com/caos/zitadel/internal/auth_request/model"
|
2020-06-11 13:22:24 +02:00
|
|
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
2020-06-05 07:50:04 +02:00
|
|
|
"github.com/caos/zitadel/internal/i18n"
|
2020-12-02 17:00:04 +01:00
|
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
2020-06-05 07:50:04 +02:00
|
|
|
"github.com/caos/zitadel/internal/renderer"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
tmplError = "error"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Renderer struct {
|
|
|
|
*renderer.Renderer
|
2020-07-08 13:56:37 +02:00
|
|
|
pathPrefix string
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
2020-07-08 13:56:37 +02:00
|
|
|
func CreateRenderer(pathPrefix string, staticDir http.FileSystem, cookieName string, defaultLanguage language.Tag) *Renderer {
|
|
|
|
r := &Renderer{
|
|
|
|
pathPrefix: pathPrefix,
|
|
|
|
}
|
2020-06-05 07:50:04 +02:00
|
|
|
tmplMapping := map[string]string{
|
2020-12-02 17:00:04 +01:00
|
|
|
tmplError: "error.html",
|
|
|
|
tmplLogin: "login.html",
|
|
|
|
tmplUserSelection: "select_user.html",
|
|
|
|
tmplPassword: "password.html",
|
|
|
|
tmplPasswordlessVerification: "passwordless.html",
|
|
|
|
tmplMFAVerify: "mfa_verify.html",
|
|
|
|
tmplMFAPrompt: "mfa_prompt.html",
|
|
|
|
tmplMFAInitVerify: "mfa_init_verify.html",
|
|
|
|
tmplMFAU2FInit: "mfa_init_u2f.html",
|
|
|
|
tmplU2FVerification: "mfa_verification_u2f.html",
|
|
|
|
tmplMFAInitDone: "mfa_init_done.html",
|
|
|
|
tmplMailVerification: "mail_verification.html",
|
|
|
|
tmplMailVerified: "mail_verified.html",
|
|
|
|
tmplInitPassword: "init_password.html",
|
|
|
|
tmplInitPasswordDone: "init_password_done.html",
|
|
|
|
tmplInitUser: "init_user.html",
|
|
|
|
tmplInitUserDone: "init_user_done.html",
|
|
|
|
tmplPasswordResetDone: "password_reset_done.html",
|
|
|
|
tmplChangePassword: "change_password.html",
|
|
|
|
tmplChangePasswordDone: "change_password_done.html",
|
|
|
|
tmplRegisterOption: "register_option.html",
|
|
|
|
tmplRegister: "register.html",
|
|
|
|
tmplLogoutDone: "logout_done.html",
|
|
|
|
tmplRegisterOrg: "register_org.html",
|
|
|
|
tmplChangeUsername: "change_username.html",
|
|
|
|
tmplChangeUsernameDone: "change_username_done.html",
|
|
|
|
tmplLinkUsersDone: "link_users_done.html",
|
|
|
|
tmplExternalNotFoundOption: "external_not_found_option.html",
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
funcs := map[string]interface{}{
|
|
|
|
"resourceUrl": func(file string) string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointResources, file)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"resourceThemeUrl": func(file, theme string) string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointResources, "themes", theme, file)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"loginUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointLogin)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
2020-09-18 13:26:28 +02:00
|
|
|
"externalIDPAuthURL": func(authReqID, idpConfigID string) string {
|
|
|
|
return path.Join(r.pathPrefix, fmt.Sprintf("%s?%s=%s&%s=%s", EndpointExternalLogin, queryAuthRequestID, authReqID, queryIDPConfigID, idpConfigID))
|
|
|
|
},
|
|
|
|
"externalIDPRegisterURL": func(authReqID, idpConfigID string) string {
|
|
|
|
return path.Join(r.pathPrefix, fmt.Sprintf("%s?%s=%s&%s=%s", EndpointExternalRegister, queryAuthRequestID, authReqID, queryIDPConfigID, idpConfigID))
|
|
|
|
},
|
2020-06-05 07:50:04 +02:00
|
|
|
"registerUrl": func(id string) string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, fmt.Sprintf("%s?%s=%s", EndpointRegister, queryAuthRequestID, id))
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
2020-06-17 08:06:40 +02:00
|
|
|
"loginNameUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointLoginName)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
2020-06-17 08:06:40 +02:00
|
|
|
"loginNameChangeUrl": func(id string) string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, fmt.Sprintf("%s?%s=%s", EndpointLoginName, queryAuthRequestID, id))
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"userSelectionUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointUserSelection)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
2020-12-02 17:00:04 +01:00
|
|
|
"passwordLessVerificationUrl": func() string {
|
|
|
|
return path.Join(r.pathPrefix, EndpointPasswordlessLogin)
|
|
|
|
},
|
2020-06-05 07:50:04 +02:00
|
|
|
"passwordResetUrl": func(id string) string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, fmt.Sprintf("%s?%s=%s", EndpointPasswordReset, queryAuthRequestID, id))
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"passwordUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointPassword)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"mfaVerifyUrl": func() string {
|
2020-12-02 17:00:04 +01:00
|
|
|
return path.Join(r.pathPrefix, EndpointMFAVerify)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"mfaPromptUrl": func() string {
|
2020-12-02 17:00:04 +01:00
|
|
|
return path.Join(r.pathPrefix, EndpointMFAPrompt)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
2020-11-04 11:26:10 +01:00
|
|
|
"mfaPromptChangeUrl": func(id string, provider model.MFAType) string {
|
2020-12-02 17:00:04 +01:00
|
|
|
return path.Join(r.pathPrefix, fmt.Sprintf("%s?%s=%s;%s=%v", EndpointMFAPrompt, queryAuthRequestID, id, "provider", provider))
|
2020-07-22 11:43:32 +02:00
|
|
|
},
|
2020-06-05 07:50:04 +02:00
|
|
|
"mfaInitVerifyUrl": func() string {
|
2020-12-02 17:00:04 +01:00
|
|
|
return path.Join(r.pathPrefix, EndpointMFAInitVerify)
|
|
|
|
},
|
|
|
|
"mfaInitU2FVerifyUrl": func() string {
|
|
|
|
return path.Join(r.pathPrefix, EndpointMFAInitU2FVerify)
|
|
|
|
},
|
|
|
|
"mfaInitU2FLoginUrl": func() string {
|
|
|
|
return path.Join(r.pathPrefix, EndpointU2FVerification)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"mailVerificationUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointMailVerification)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"initPasswordUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointInitPassword)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"initUserUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointInitUser)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
|
|
|
"changePasswordUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointChangePassword)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
2020-09-18 13:26:28 +02:00
|
|
|
"registerOptionUrl": func() string {
|
|
|
|
return path.Join(r.pathPrefix, EndpointRegisterOption)
|
|
|
|
},
|
2020-06-05 07:50:04 +02:00
|
|
|
"registrationUrl": func() string {
|
2020-07-08 13:56:37 +02:00
|
|
|
return path.Join(r.pathPrefix, EndpointRegister)
|
2020-06-05 07:50:04 +02:00
|
|
|
},
|
2020-08-06 14:38:19 +02:00
|
|
|
"orgRegistrationUrl": func() string {
|
|
|
|
return path.Join(r.pathPrefix, EndpointRegisterOrg)
|
|
|
|
},
|
2020-08-27 17:18:23 +02:00
|
|
|
"changeUsernameUrl": func() string {
|
|
|
|
return path.Join(r.pathPrefix, EndpointChangeUsername)
|
|
|
|
},
|
2020-09-18 13:26:28 +02:00
|
|
|
"externalNotFoundOptionUrl": func() string {
|
|
|
|
return path.Join(r.pathPrefix, EndpointExternalNotFoundOption)
|
|
|
|
},
|
2020-06-05 07:50:04 +02:00
|
|
|
"selectedLanguage": func(l string) bool {
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
"selectedGender": func(g int32) bool {
|
|
|
|
return false
|
|
|
|
},
|
2020-09-21 14:06:54 +02:00
|
|
|
"hasExternalLogin": func() bool {
|
|
|
|
return false
|
|
|
|
},
|
2020-10-19 17:10:02 +02:00
|
|
|
"idpProviderClass": func(stylingType iam_model.IDPStylingType) string {
|
|
|
|
return stylingType.GetCSSClass()
|
|
|
|
},
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
var err error
|
|
|
|
r.Renderer, err = renderer.NewRenderer(
|
|
|
|
staticDir,
|
|
|
|
tmplMapping, funcs,
|
|
|
|
i18n.TranslatorConfig{DefaultLanguage: defaultLanguage, CookieName: cookieName},
|
|
|
|
)
|
|
|
|
logging.Log("APP-40tSoJ").OnError(err).WithError(err).Panic("error creating renderer")
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) renderNextStep(w http.ResponseWriter, r *http.Request, authReq *model.AuthRequest) {
|
2020-08-31 08:49:35 +02:00
|
|
|
userAgentID, _ := http_mw.UserAgentIDFromCtx(r.Context())
|
|
|
|
authReq, err := l.authRepo.AuthRequestByID(r.Context(), authReq.ID, userAgentID)
|
2020-06-05 07:50:04 +02:00
|
|
|
if err != nil {
|
2020-11-04 11:26:10 +01:00
|
|
|
l.renderInternalError(w, r, authReq, caos_errs.ThrowInternal(err, "APP-sio0W", "could not get authreq"))
|
2020-10-02 08:02:09 +02:00
|
|
|
return
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
if len(authReq.PossibleSteps) == 0 {
|
2020-06-11 13:22:24 +02:00
|
|
|
l.renderInternalError(w, r, authReq, caos_errs.ThrowInternal(nil, "APP-9sdp4", "no possible steps"))
|
2020-06-05 07:50:04 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
l.chooseNextStep(w, r, authReq, 0, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) renderError(w http.ResponseWriter, r *http.Request, authReq *model.AuthRequest, err error) {
|
|
|
|
if authReq == nil || len(authReq.PossibleSteps) == 0 {
|
2020-06-11 13:22:24 +02:00
|
|
|
l.renderInternalError(w, r, authReq, caos_errs.ThrowInternal(err, "APP-OVOiT", "no possible steps"))
|
2020-06-05 07:50:04 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
l.chooseNextStep(w, r, authReq, 0, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) chooseNextStep(w http.ResponseWriter, r *http.Request, authReq *model.AuthRequest, stepNumber int, err error) {
|
|
|
|
switch step := authReq.PossibleSteps[stepNumber].(type) {
|
|
|
|
case *model.LoginStep:
|
|
|
|
if len(authReq.PossibleSteps) > 1 {
|
|
|
|
l.chooseNextStep(w, r, authReq, 1, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
l.renderLogin(w, r, authReq, err)
|
|
|
|
case *model.SelectUserStep:
|
|
|
|
l.renderUserSelection(w, r, authReq, step)
|
|
|
|
case *model.InitPasswordStep:
|
|
|
|
l.renderInitPassword(w, r, authReq, authReq.UserID, "", err)
|
|
|
|
case *model.PasswordStep:
|
|
|
|
l.renderPassword(w, r, authReq, nil)
|
2020-12-02 17:00:04 +01:00
|
|
|
case *model.PasswordlessStep:
|
|
|
|
l.renderPasswordlessVerification(w, r, authReq, nil)
|
|
|
|
case *model.MFAVerificationStep:
|
|
|
|
l.renderMFAVerify(w, r, authReq, step, err)
|
2020-06-05 07:50:04 +02:00
|
|
|
case *model.RedirectToCallbackStep:
|
|
|
|
if len(authReq.PossibleSteps) > 1 {
|
|
|
|
l.chooseNextStep(w, r, authReq, 1, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
l.redirectToCallback(w, r, authReq)
|
|
|
|
case *model.ChangePasswordStep:
|
|
|
|
l.renderChangePassword(w, r, authReq, err)
|
|
|
|
case *model.VerifyEMailStep:
|
|
|
|
l.renderMailVerification(w, r, authReq, "", err)
|
2020-12-02 17:00:04 +01:00
|
|
|
case *model.MFAPromptStep:
|
|
|
|
l.renderMFAPrompt(w, r, authReq, step, err)
|
2020-06-05 07:50:04 +02:00
|
|
|
case *model.InitUserStep:
|
2020-06-19 14:52:04 +02:00
|
|
|
l.renderInitUser(w, r, authReq, "", "", step.PasswordSet, nil)
|
2020-08-27 17:18:23 +02:00
|
|
|
case *model.ChangeUsernameStep:
|
|
|
|
l.renderChangeUsername(w, r, authReq, nil)
|
2020-09-18 13:26:28 +02:00
|
|
|
case *model.LinkUsersStep:
|
|
|
|
l.linkUsers(w, r, authReq, err)
|
|
|
|
case *model.ExternalNotFoundOptionStep:
|
|
|
|
l.renderExternalNotFoundOption(w, r, authReq, err)
|
2020-10-02 08:02:09 +02:00
|
|
|
case *model.ExternalLoginStep:
|
|
|
|
l.handleExternalLoginStep(w, r, authReq, step.SelectedIDPConfigID)
|
2020-10-16 07:49:38 +02:00
|
|
|
case *model.GrantRequiredStep:
|
|
|
|
l.renderInternalError(w, r, authReq, caos_errs.ThrowPreconditionFailed(nil, "APP-asb43", "Errors.User.GrantRequired"))
|
2020-06-05 07:50:04 +02:00
|
|
|
default:
|
2020-06-11 13:22:24 +02:00
|
|
|
l.renderInternalError(w, r, authReq, caos_errs.ThrowInternal(nil, "APP-ds3QF", "step no possible"))
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) renderInternalError(w http.ResponseWriter, r *http.Request, authReq *model.AuthRequest, err error) {
|
|
|
|
var msg string
|
|
|
|
if err != nil {
|
|
|
|
msg = err.Error()
|
|
|
|
}
|
|
|
|
data := l.getBaseData(r, authReq, "Error", "Internal", msg)
|
|
|
|
l.renderer.RenderTemplate(w, r, l.renderer.Templates[tmplError], data, nil)
|
|
|
|
}
|
|
|
|
|
2020-07-20 10:00:29 +02:00
|
|
|
func (l *Login) getUserData(r *http.Request, authReq *model.AuthRequest, title string, errType, errMessage string) userData {
|
2020-10-07 10:46:22 +02:00
|
|
|
userData := userData{
|
2020-07-20 10:00:29 +02:00
|
|
|
baseData: l.getBaseData(r, authReq, title, errType, errMessage),
|
|
|
|
profileData: l.getProfileData(authReq),
|
|
|
|
}
|
2020-10-07 10:46:22 +02:00
|
|
|
if authReq != nil && authReq.LinkingUsers != nil {
|
|
|
|
userData.Linking = len(authReq.LinkingUsers) > 0
|
|
|
|
}
|
|
|
|
return userData
|
2020-07-20 10:00:29 +02:00
|
|
|
}
|
|
|
|
|
2020-06-05 07:50:04 +02:00
|
|
|
func (l *Login) getBaseData(r *http.Request, authReq *model.AuthRequest, title string, errType, errMessage string) baseData {
|
2020-09-18 13:26:28 +02:00
|
|
|
baseData := baseData{
|
2020-06-05 07:50:04 +02:00
|
|
|
errorData: errorData{
|
|
|
|
ErrType: errType,
|
|
|
|
ErrMessage: errMessage,
|
|
|
|
},
|
|
|
|
Lang: l.renderer.Lang(r).String(),
|
|
|
|
Title: title,
|
|
|
|
Theme: l.getTheme(r),
|
|
|
|
ThemeMode: l.getThemeMode(r),
|
2020-09-18 13:26:28 +02:00
|
|
|
OrgID: l.getOrgID(authReq),
|
2020-12-14 10:54:29 +01:00
|
|
|
OrgName: l.getOrgName(authReq),
|
2020-06-05 07:50:04 +02:00
|
|
|
AuthReqID: getRequestID(authReq, r),
|
2020-06-17 08:06:40 +02:00
|
|
|
CSRF: csrf.TemplateField(r),
|
2020-08-31 08:49:35 +02:00
|
|
|
Nonce: http_mw.GetNonce(r),
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
2020-09-18 13:26:28 +02:00
|
|
|
if authReq != nil {
|
|
|
|
baseData.LoginPolicy = authReq.LoginPolicy
|
|
|
|
baseData.IDPProviders = authReq.AllowedExternalIDPs
|
|
|
|
}
|
|
|
|
return baseData
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
2020-07-20 10:00:29 +02:00
|
|
|
func (l *Login) getProfileData(authReq *model.AuthRequest) profileData {
|
|
|
|
var loginName, displayName string
|
|
|
|
if authReq != nil {
|
|
|
|
loginName = authReq.LoginName
|
|
|
|
displayName = authReq.DisplayName
|
|
|
|
}
|
|
|
|
return profileData{
|
|
|
|
LoginName: loginName,
|
|
|
|
DisplayName: displayName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 13:22:24 +02:00
|
|
|
func (l *Login) getErrorMessage(r *http.Request, err error) (errMsg string) {
|
|
|
|
caosErr := new(caos_errs.CaosError)
|
|
|
|
if errors.As(err, &caosErr) {
|
|
|
|
localized := l.renderer.LocalizeFromRequest(r, caosErr.Message, nil)
|
|
|
|
return localized + " (" + caosErr.ID + ")"
|
|
|
|
|
|
|
|
}
|
|
|
|
return err.Error()
|
|
|
|
}
|
|
|
|
|
2020-06-05 07:50:04 +02:00
|
|
|
func (l *Login) getTheme(r *http.Request) string {
|
|
|
|
return "zitadel" //TODO: impl
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) getThemeMode(r *http.Request) string {
|
feat(login): new palette based styles (#1149)
* chore(deps-dev): bump rollup from 2.33.2 to 2.34.0 in /site (#1040)
Bumps [rollup](https://github.com/rollup/rollup) from 2.33.2 to 2.34.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.33.2...v2.34.0)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump svelte-i18n from 3.2.5 to 3.3.0 in /site (#1039)
Bumps [svelte-i18n](https://github.com/kaisermann/svelte-i18n) from 3.2.5 to 3.3.0.
- [Release notes](https://github.com/kaisermann/svelte-i18n/releases)
- [Changelog](https://github.com/kaisermann/svelte-i18n/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kaisermann/svelte-i18n/compare/v3.2.5...v3.3.0)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps-dev): bump @rollup/plugin-url from 5.0.1 to 6.0.0 in /site (#1038)
Bumps [@rollup/plugin-url](https://github.com/rollup/plugins) from 5.0.1 to 6.0.0.
- [Release notes](https://github.com/rollup/plugins/releases)
- [Commits](https://github.com/rollup/plugins/compare/url-v5.0.1...url-v6.0.0)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps-dev): bump svelte from 3.29.7 to 3.30.1 in /site (#1037)
Bumps [svelte](https://github.com/sveltejs/svelte) from 3.29.7 to 3.30.1.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/compare/v3.29.7...v3.30.1)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump marked from 1.2.4 to 1.2.5 in /site (#1036)
Bumps [marked](https://github.com/markedjs/marked) from 1.2.4 to 1.2.5.
- [Release notes](https://github.com/markedjs/marked/releases)
- [Changelog](https://github.com/markedjs/marked/blob/master/release.config.js)
- [Commits](https://github.com/markedjs/marked/compare/v1.2.4...v1.2.5)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps-dev): bump @babel/core from 7.12.3 to 7.12.9 in /site (#1035)
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.12.3 to 7.12.9.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.12.9/packages/babel-core)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps-dev): bump rollup-plugin-svelte from 6.1.1 to 7.0.0 in /site (#1034)
Bumps [rollup-plugin-svelte](https://github.com/sveltejs/rollup-plugin-svelte) from 6.1.1 to 7.0.0.
- [Release notes](https://github.com/sveltejs/rollup-plugin-svelte/releases)
- [Changelog](https://github.com/sveltejs/rollup-plugin-svelte/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/rollup-plugin-svelte/compare/v6.1.1...v7.0.0)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps-dev): bump @rollup/plugin-commonjs in /site (#1033)
Bumps [@rollup/plugin-commonjs](https://github.com/rollup/plugins) from 15.1.0 to 17.0.0.
- [Release notes](https://github.com/rollup/plugins/releases)
- [Commits](https://github.com/rollup/plugins/compare/commonjs-v15.1.0...commonjs-v17.0.0)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps-dev): bump @rollup/plugin-node-resolve in /site (#1032)
Bumps [@rollup/plugin-node-resolve](https://github.com/rollup/plugins) from 10.0.0 to 11.0.0.
- [Release notes](https://github.com/rollup/plugins/releases)
- [Commits](https://github.com/rollup/plugins/compare/node-resolve-v10.0.0...commonjs-v11.0.0)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps-dev): bump @babel/preset-env from 7.12.1 to 7.12.7 in /site (#1031)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.12.1 to 7.12.7.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.12.7/packages/babel-preset-env)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* go
* bundle files, lgn-color, legacy theme
* remove old references
* light dark context, button styles, zitadel brand
* button theme, edit templates
* typography theme mixins
* input styles, container, extend light dark palette
* footer, palette, container
* container, label, assets, header
* action container, input, typography label, adapt button theme
* a and footer styles, adapt palette
* user log profile, resourcetempurl
* postinstall againnn
* wrochage
* rm local grpc
* button elevation, helper for components
* radio
* radio button mixins, bundle
* qr code styles, secret clipboard, icon pack
* stroked buttons, icon buttons, header action, typography
* fix password policy styles
* account selection
* account selection, lgn avatar
* mocks
* template fixes, animations scss
* checkbox, register temp
* checkbox appr
* fix checkbox, remove input interference
* select theme
* avatar script, user selection, password policy validation fix
* fix formfield state for register and change pwd
* footer, main style, qr code fix, mfa type fix, account sel, checkbox
* fotter tos, user select
* reverse buttons for intial submit action
* theme script, themed error messages, header img source
* content wrapper, i18n, mobile
* emptyline
* idp mixins, fix unstyled html
* register container
* register layout, list themes, policy theme, register org
* massive asset cleanup
* fix source path, add missing icon, fix complexity refs, prefix
* remove material icons, unused assets, fix icon font
* move icon pack
* avatar, contrast theme, error fix
* zitadel css map
* revert go mod
* fix mfa verify actions
* add idp styles
* fix google colors, idp styles
* fix: bugs
* fix register options, google
* fix script, mobile layout
* precompile font selection
* go mod tidy
* assets and cleanup
* input suffix, fix alignment, actions, add progress bar themes
* progress bar mixins, layout fixes
* remove test from loginname
* cleanup comments, scripts
* clear comments
* fix external back button
* fix mfa alignment
* fix actions layout, on dom change listener for suffix
* free tier change, success label
* fix: button font line-height
* remove tabindex
* remove comment
* remove comment
* Update internal/ui/login/handler/password_handler.go
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Peintner <csaq7175@uibk.ac.at>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-02-02 07:07:00 +01:00
|
|
|
return "lgn-dark-theme" //TODO: impl
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
2020-09-18 13:26:28 +02:00
|
|
|
func (l *Login) getOrgID(authReq *model.AuthRequest) string {
|
|
|
|
if authReq == nil {
|
|
|
|
return ""
|
|
|
|
}
|
2020-12-14 10:54:29 +01:00
|
|
|
if authReq.RequestedOrgID != "" {
|
|
|
|
return authReq.RequestedOrgID
|
2020-09-18 13:26:28 +02:00
|
|
|
}
|
2020-12-14 10:54:29 +01:00
|
|
|
return authReq.UserOrgID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) getOrgName(authReq *model.AuthRequest) string {
|
|
|
|
if authReq == nil {
|
2020-09-18 13:26:28 +02:00
|
|
|
return ""
|
|
|
|
}
|
2020-12-14 10:54:29 +01:00
|
|
|
return authReq.RequestedOrgName
|
2020-09-18 13:26:28 +02:00
|
|
|
}
|
|
|
|
|
2020-06-05 07:50:04 +02:00
|
|
|
func getRequestID(authReq *model.AuthRequest, r *http.Request) string {
|
|
|
|
if authReq != nil {
|
|
|
|
return authReq.ID
|
|
|
|
}
|
|
|
|
return r.FormValue(queryAuthRequestID)
|
|
|
|
}
|
|
|
|
|
2020-06-17 08:06:40 +02:00
|
|
|
func (l *Login) csrfErrorHandler() http.Handler {
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
err := csrf.FailureReason(r)
|
|
|
|
l.renderInternalError(w, r, nil, err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) cspErrorHandler(err error) http.Handler {
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
l.renderInternalError(w, r, nil, err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-06-05 07:50:04 +02:00
|
|
|
type baseData struct {
|
|
|
|
errorData
|
2020-09-18 13:26:28 +02:00
|
|
|
Lang string
|
|
|
|
Title string
|
|
|
|
Theme string
|
|
|
|
ThemeMode string
|
|
|
|
OrgID string
|
2020-12-14 10:54:29 +01:00
|
|
|
OrgName string
|
2020-09-18 13:26:28 +02:00
|
|
|
AuthReqID string
|
|
|
|
CSRF template.HTML
|
|
|
|
Nonce string
|
|
|
|
LoginPolicy *iam_model.LoginPolicyView
|
|
|
|
IDPProviders []*iam_model.IDPProviderView
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type errorData struct {
|
|
|
|
ErrType string
|
|
|
|
ErrMessage string
|
|
|
|
}
|
|
|
|
|
|
|
|
type userData struct {
|
|
|
|
baseData
|
2020-07-20 10:00:29 +02:00
|
|
|
profileData
|
2020-06-05 07:50:04 +02:00
|
|
|
PasswordChecked string
|
2020-12-02 17:00:04 +01:00
|
|
|
MFAProviders []model.MFAType
|
|
|
|
SelectedMFAProvider model.MFAType
|
2020-09-18 13:26:28 +02:00
|
|
|
Linking bool
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
2020-07-20 10:00:29 +02:00
|
|
|
type profileData struct {
|
|
|
|
LoginName string
|
|
|
|
DisplayName string
|
|
|
|
}
|
|
|
|
|
2020-07-16 14:26:08 +02:00
|
|
|
type passwordData struct {
|
|
|
|
baseData
|
2020-07-20 10:00:29 +02:00
|
|
|
profileData
|
2020-07-16 14:26:08 +02:00
|
|
|
PasswordPolicyDescription string
|
|
|
|
MinLength uint64
|
|
|
|
HasUppercase string
|
|
|
|
HasLowercase string
|
|
|
|
HasNumber string
|
|
|
|
HasSymbol string
|
|
|
|
}
|
|
|
|
|
2020-06-05 07:50:04 +02:00
|
|
|
type userSelectionData struct {
|
|
|
|
baseData
|
2020-09-18 13:26:28 +02:00
|
|
|
Users []model.UserSelection
|
|
|
|
Linking bool
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type mfaData struct {
|
|
|
|
baseData
|
2020-07-20 10:00:29 +02:00
|
|
|
profileData
|
2020-12-02 17:00:04 +01:00
|
|
|
MFAProviders []model.MFAType
|
|
|
|
MFARequired bool
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type mfaVerifyData struct {
|
|
|
|
baseData
|
2020-07-20 10:00:29 +02:00
|
|
|
profileData
|
2020-12-02 17:00:04 +01:00
|
|
|
MFAType model.MFAType
|
2020-06-05 07:50:04 +02:00
|
|
|
otpData
|
|
|
|
}
|
|
|
|
|
|
|
|
type mfaDoneData struct {
|
|
|
|
baseData
|
2020-07-20 10:00:29 +02:00
|
|
|
profileData
|
2020-12-02 17:00:04 +01:00
|
|
|
MFAType model.MFAType
|
2020-06-05 07:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type otpData struct {
|
|
|
|
Url string
|
|
|
|
Secret string
|
|
|
|
QrCode string
|
|
|
|
}
|