feat: multiple domains (#188)

* check uniqueness on create and register user

* change user email, reserve release unique email

* usergrant unique aggregate

* usergrant uniqueness

* validate UserGrant

* fix tests

* domain is set on username in all orgs

* domain in admin

* org domain sql

* zitadel domain org name

* org domains

* org iam policy

* default org iam policy

* SETUP

* load login names

* login by login name

* login name

* fix: merge master

* fix: merge master

* Update internal/user/repository/eventsourcing/user.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix: fix unique domains

* fix: rename env variable

Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi
2020-06-16 11:40:18 +02:00
committed by GitHub
parent 64b14b4e19
commit 7a6ca24625
109 changed files with 12578 additions and 6025 deletions

View File

@@ -1,9 +1,11 @@
package model
import (
"time"
caos_errors "github.com/caos/zitadel/internal/errors"
org_model "github.com/caos/zitadel/internal/org/model"
policy_model "github.com/caos/zitadel/internal/policy/model"
"strings"
"time"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/caos/zitadel/internal/crypto"
@@ -66,10 +68,17 @@ const (
GENDER_DIVERSE
)
func (u *User) SetEmailAsUsername() {
if u.Profile != nil && u.UserName == "" && u.Email != nil {
func (u *User) CheckOrgIamPolicy(policy *org_model.OrgIamPolicy) error {
if policy == nil {
return caos_errors.ThrowPreconditionFailed(nil, "MODEL-zSH7j", "Org Iam Policy should not be nil")
}
if policy.UserLoginMustBeDomain && strings.Contains(u.UserName, "@") {
return caos_errors.ThrowPreconditionFailed(nil, "MODEL-se4sJ", "Username should not be email address")
}
if !policy.UserLoginMustBeDomain && u.Profile != nil && u.UserName == "" && u.Email != nil {
u.UserName = u.EmailAddress
}
return nil
}
func (u *User) IsValid() bool {

View File

@@ -44,7 +44,7 @@ const (
type UserSessionSearchQuery struct {
Key UserSessionSearchKey
Method model.SearchMethod
Value string
Value interface{}
}
type UserSessionSearchResponse struct {

View File

@@ -18,6 +18,7 @@ type UserView struct {
PasswordChanged time.Time
LastLogin time.Time
UserName string
LoginNames []string
FirstName string
LastName string
NickName string
@@ -61,12 +62,13 @@ const (
USERSEARCHKEY_EMAIL
USERSEARCHKEY_STATE
USERSEARCHKEY_RESOURCEOWNER
USERSEARCHKEY_LOGIN_NAMES
)
type UserSearchQuery struct {
Key UserSearchKey
Method model.SearchMethod
Value string
Value interface{}
}
type UserSearchResponse struct {