mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-25 05:58:45 +00:00
feat: handle Zitadel provider IdP login via login v1 (#12469)
# Which Problems Are Solved This PR adds support for using a ZITADEL IdP provider in the login v1 UI flow and conditionally grants a support-user instance membership based on a ZITADEL-specific project-roles token claim. # How the Problems Are Solved - Introduced ZITADEL IdP handling in the login v1 handler, including extracting the `urn:zitadel:iam:org:project:roles` claim and granting `IAM_OWNER_VIEWER` instance membership when configured orgs match. - Added a new `AddInstanceMemberFromLogin` to assign an instance membership during the login v1 ZITADEL-IdP flow without permission checks (as the authorization is established based on the project roles in the token claim) - Added unit tests # Additional Changes N/A # Additional Context - Closes https://github.com/zitadel/zitadel/issues/12446
This commit is contained in:
@@ -207,34 +207,6 @@ func Test_addZitadelProviderToCommand(t *testing.T) {
|
||||
req *mgmt_pb.AddZitadelProviderRequest
|
||||
want command.ZitadelProvider
|
||||
}{
|
||||
{
|
||||
name: "without instance roles info",
|
||||
req: &mgmt_pb.AddZitadelProviderRequest{
|
||||
Name: "Zitadel Support IdP",
|
||||
ClientId: "test-client",
|
||||
ClientSecret: "test-secret",
|
||||
Scopes: []string{"email", "profile", "urn:zitadel:iam:org:project:roles"},
|
||||
ProviderOptions: &idp_pb.Options{
|
||||
IsLinkingAllowed: false,
|
||||
IsCreationAllowed: true,
|
||||
IsAutoCreation: false,
|
||||
IsAutoUpdate: true,
|
||||
AutoLinking: 0,
|
||||
},
|
||||
},
|
||||
want: command.ZitadelProvider{
|
||||
Name: "Zitadel Support IdP",
|
||||
ClientID: "test-client",
|
||||
ClientSecret: "test-secret",
|
||||
Scopes: []string{"email", "profile", "urn:zitadel:iam:org:project:roles"},
|
||||
IDPOptions: idp.Options{
|
||||
IsCreationAllowed: true,
|
||||
IsAutoCreation: false,
|
||||
IsLinkingAllowed: false,
|
||||
IsAutoUpdate: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields filled",
|
||||
req: &mgmt_pb.AddZitadelProviderRequest{
|
||||
@@ -249,17 +221,6 @@ func Test_addZitadelProviderToCommand(t *testing.T) {
|
||||
IsAutoUpdate: true,
|
||||
AutoLinking: 0,
|
||||
},
|
||||
InstanceRolesInfo: []*idp_pb.InstanceRolesInfo{
|
||||
{
|
||||
OrganizationId: "org1",
|
||||
OrganizationDomain: "org1.com",
|
||||
},
|
||||
{
|
||||
|
||||
OrganizationId: "org2",
|
||||
OrganizationDomain: "org2.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: command.ZitadelProvider{
|
||||
Name: "Zitadel Support IdP",
|
||||
@@ -272,16 +233,6 @@ func Test_addZitadelProviderToCommand(t *testing.T) {
|
||||
IsLinkingAllowed: false,
|
||||
IsAutoUpdate: true,
|
||||
},
|
||||
InstanceRolesInfo: []idp.RolesInfo{
|
||||
{
|
||||
OrganizationID: "org1",
|
||||
OrganizationDomain: "org1.com",
|
||||
},
|
||||
{
|
||||
OrganizationID: "org2",
|
||||
OrganizationDomain: "org2.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -301,35 +252,6 @@ func Test_updateZitadelProviderToCommand(t *testing.T) {
|
||||
req *mgmt_pb.UpdateZitadelProviderRequest
|
||||
want command.ZitadelProvider
|
||||
}{
|
||||
{
|
||||
name: "without instance roles info",
|
||||
req: &mgmt_pb.UpdateZitadelProviderRequest{
|
||||
Name: "Zitadel Support IdP",
|
||||
ClientId: "test-client",
|
||||
ClientSecret: "test-secret",
|
||||
Scopes: []string{"email", "profile", "urn:zitadel:iam:org:project:roles"},
|
||||
ProviderOptions: &idp_pb.Options{
|
||||
IsLinkingAllowed: false,
|
||||
IsCreationAllowed: true,
|
||||
IsAutoCreation: false,
|
||||
IsAutoUpdate: true,
|
||||
AutoLinking: 0,
|
||||
},
|
||||
},
|
||||
want: command.ZitadelProvider{
|
||||
Name: "Zitadel Support IdP",
|
||||
ClientID: "test-client",
|
||||
ClientSecret: "test-secret",
|
||||
Scopes: []string{"email", "profile", "urn:zitadel:iam:org:project:roles"},
|
||||
IDPOptions: idp.Options{
|
||||
IsCreationAllowed: true,
|
||||
IsAutoCreation: false,
|
||||
IsLinkingAllowed: false,
|
||||
IsAutoUpdate: true,
|
||||
},
|
||||
InstanceRolesInfo: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields filled",
|
||||
req: &mgmt_pb.UpdateZitadelProviderRequest{
|
||||
@@ -344,17 +266,6 @@ func Test_updateZitadelProviderToCommand(t *testing.T) {
|
||||
IsAutoUpdate: true,
|
||||
AutoLinking: 0,
|
||||
},
|
||||
InstanceRolesInfo: []*idp_pb.InstanceRolesInfo{
|
||||
{
|
||||
OrganizationId: "org1",
|
||||
OrganizationDomain: "org1.com",
|
||||
},
|
||||
{
|
||||
|
||||
OrganizationId: "org2",
|
||||
OrganizationDomain: "org2.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: command.ZitadelProvider{
|
||||
Name: "Zitadel Support IdP",
|
||||
@@ -367,16 +278,6 @@ func Test_updateZitadelProviderToCommand(t *testing.T) {
|
||||
IsLinkingAllowed: false,
|
||||
IsAutoUpdate: true,
|
||||
},
|
||||
InstanceRolesInfo: []idp.RolesInfo{
|
||||
{
|
||||
OrganizationID: "org1",
|
||||
OrganizationDomain: "org1.com",
|
||||
},
|
||||
{
|
||||
OrganizationID: "org2",
|
||||
OrganizationDomain: "org2.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user