mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-05 02:18:48 +00:00
feat: select idp and auto register (#2336)
* faet: auto regsiter config on idp * feat: auto register on login * feat: auto register on register * feat: redirect to selected identity provider * fix: test * fix: test * fix: user by id request org id * fix: migration version and test Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
@@ -68,6 +68,7 @@ func TestCommandSide_AddDefaultIDPConfig(t *testing.T) {
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
domain.IDPConfigStylingTypeGoogle,
|
||||
true,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -99,8 +100,9 @@ func TestCommandSide_AddDefaultIDPConfig(t *testing.T) {
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
config: &domain.IDPConfig{
|
||||
Name: "name1",
|
||||
StylingType: domain.IDPConfigStylingTypeGoogle,
|
||||
Name: "name1",
|
||||
StylingType: domain.IDPConfigStylingTypeGoogle,
|
||||
AutoRegister: true,
|
||||
OIDCConfig: &domain.OIDCIDPConfig{
|
||||
ClientID: "clientid1",
|
||||
Issuer: "issuer",
|
||||
@@ -119,10 +121,11 @@ func TestCommandSide_AddDefaultIDPConfig(t *testing.T) {
|
||||
AggregateID: "IAM",
|
||||
ResourceOwner: "IAM",
|
||||
},
|
||||
IDPConfigID: "config1",
|
||||
Name: "name1",
|
||||
StylingType: domain.IDPConfigStylingTypeGoogle,
|
||||
State: domain.IDPConfigStateActive,
|
||||
IDPConfigID: "config1",
|
||||
Name: "name1",
|
||||
StylingType: domain.IDPConfigStylingTypeGoogle,
|
||||
State: domain.IDPConfigStateActive,
|
||||
AutoRegister: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -212,6 +215,7 @@ func TestCommandSide_ChangeDefaultIDPConfig(t *testing.T) {
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
domain.IDPConfigStylingTypeGoogle,
|
||||
true,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -237,7 +241,7 @@ func TestCommandSide_ChangeDefaultIDPConfig(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
newDefaultIDPConfigChangedEvent(context.Background(), "config1", "name1", "name2", domain.IDPConfigStylingTypeUnspecified),
|
||||
newDefaultIDPConfigChangedEvent(context.Background(), "config1", "name1", "name2", domain.IDPConfigStylingTypeUnspecified, false),
|
||||
),
|
||||
},
|
||||
uniqueConstraintsFromEventConstraint(idpconfig.NewRemoveIDPConfigNameUniqueConstraint("name1", "IAM")),
|
||||
@@ -248,9 +252,10 @@ func TestCommandSide_ChangeDefaultIDPConfig(t *testing.T) {
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
config: &domain.IDPConfig{
|
||||
IDPConfigID: "config1",
|
||||
Name: "name2",
|
||||
StylingType: domain.IDPConfigStylingTypeUnspecified,
|
||||
IDPConfigID: "config1",
|
||||
Name: "name2",
|
||||
StylingType: domain.IDPConfigStylingTypeUnspecified,
|
||||
AutoRegister: false,
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@@ -259,10 +264,11 @@ func TestCommandSide_ChangeDefaultIDPConfig(t *testing.T) {
|
||||
AggregateID: "IAM",
|
||||
ResourceOwner: "IAM",
|
||||
},
|
||||
IDPConfigID: "config1",
|
||||
Name: "name2",
|
||||
StylingType: domain.IDPConfigStylingTypeUnspecified,
|
||||
State: domain.IDPConfigStateActive,
|
||||
IDPConfigID: "config1",
|
||||
Name: "name2",
|
||||
StylingType: domain.IDPConfigStylingTypeUnspecified,
|
||||
State: domain.IDPConfigStateActive,
|
||||
AutoRegister: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -286,7 +292,7 @@ func TestCommandSide_ChangeDefaultIDPConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func newDefaultIDPConfigChangedEvent(ctx context.Context, configID, oldName, newName string, stylingType domain.IDPConfigStylingType) *iam.IDPConfigChangedEvent {
|
||||
func newDefaultIDPConfigChangedEvent(ctx context.Context, configID, oldName, newName string, stylingType domain.IDPConfigStylingType, autoRegister bool) *iam.IDPConfigChangedEvent {
|
||||
event, _ := iam.NewIDPConfigChangedEvent(ctx,
|
||||
&iam.NewAggregate().Aggregate,
|
||||
configID,
|
||||
@@ -294,6 +300,7 @@ func newDefaultIDPConfigChangedEvent(ctx context.Context, configID, oldName, new
|
||||
[]idpconfig.IDPConfigChanges{
|
||||
idpconfig.ChangeName(newName),
|
||||
idpconfig.ChangeStyleType(stylingType),
|
||||
idpconfig.ChangeAutoRegister(autoRegister),
|
||||
},
|
||||
)
|
||||
return event
|
||||
|
||||
Reference in New Issue
Block a user