mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-25 05:58:45 +00:00
feat: get/list Zitadel IdP (#12394)
# Which Problems Are Solved This PR extends the functionality of `GetProviderByID`, `ListProviders` v1 endpoints and `GetIDPByID` v2 endpoint to also return Zitadel IdP when queried. # How the Problems Are Solved - Add `PROVIDER_TYPE_ZITADEL` and a `ZitadelConfig` to `zitadel.idp.v1.ProviderConfig` (v1 APIs). - Add `IDP_TYPE_ZITADEL`, `ZitadelConfig`, `InstanceRolesInfo` in v2 `idp.proto` - Extend internal/query IDP template querying to include a `ZitadelIDPTemplate` (incl. issuer, client credentials, scopes, instance roles info). - Add/extend integration tests for updating + fetching providers by ID and listing providers. # Additional Changes N/A # Additional Context Closes https://github.com/zitadel/zitadel/issues/12051 --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
39ad66bded
commit
77169181a3
@@ -47,6 +47,7 @@ type IDPTemplate struct {
|
||||
*LDAPIDPTemplate
|
||||
*AppleIDPTemplate
|
||||
*SAMLIDPTemplate
|
||||
*ZitadelIDPTemplate
|
||||
}
|
||||
|
||||
type IDPTemplates struct {
|
||||
@@ -170,6 +171,15 @@ type SAMLIDPTemplate struct {
|
||||
FederatedLogoutEnabled bool
|
||||
}
|
||||
|
||||
type ZitadelIDPTemplate struct {
|
||||
IDPID string
|
||||
ClientID string
|
||||
ClientSecret *crypto.CryptoValue
|
||||
Issuer string
|
||||
Scopes database.TextArray[string]
|
||||
InstanceRolesInfo database.JSONArray[idp.RolesInfo]
|
||||
}
|
||||
|
||||
var (
|
||||
idpTemplateTable = table{
|
||||
name: projection.IDPTemplateTable,
|
||||
@@ -741,6 +751,41 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
zitadelIdpTemplateTable = table{
|
||||
name: projection.IDPTemplateZitadelTable,
|
||||
instanceIDCol: projection.ZitadelInstanceIDCol,
|
||||
}
|
||||
ZitadelIDCol = Column{
|
||||
name: projection.ZitadelIDCol,
|
||||
table: zitadelIdpTemplateTable,
|
||||
}
|
||||
ZitadelInstanceIDCol = Column{
|
||||
name: projection.ZitadelInstanceIDCol,
|
||||
table: zitadelIdpTemplateTable,
|
||||
}
|
||||
ZitadelIssuerCol = Column{
|
||||
name: projection.ZitadelIssuerCol,
|
||||
table: zitadelIdpTemplateTable,
|
||||
}
|
||||
ZitadelClientIDCol = Column{
|
||||
name: projection.ZitadelClientIDCol,
|
||||
table: zitadelIdpTemplateTable,
|
||||
}
|
||||
ZitadelClientSecretCol = Column{
|
||||
name: projection.ZitadelClientSecretCol,
|
||||
table: zitadelIdpTemplateTable,
|
||||
}
|
||||
ZitadelScopesCol = Column{
|
||||
name: projection.ZitadelScopesCol,
|
||||
table: zitadelIdpTemplateTable,
|
||||
}
|
||||
ZitadelInstanceRolesInfoCol = Column{
|
||||
name: projection.ZitadelInstanceRolesInfoCol,
|
||||
table: zitadelIdpTemplateTable,
|
||||
}
|
||||
)
|
||||
|
||||
// IDPTemplateByID searches for the requested id with permission check if necessary
|
||||
func (q *Queries) IDPTemplateByID(ctx context.Context, shouldTriggerBulk bool, id string, withOwnerRemoved bool, permissionCheck domain.PermissionCheck, queries ...SearchQuery) (template *IDPTemplate, err error) {
|
||||
idp, err := q.idpTemplateByID(ctx, shouldTriggerBulk, id, withOwnerRemoved, queries...)
|
||||
@@ -998,6 +1043,13 @@ func prepareIDPTemplateByIDQuery() (sq.SelectBuilder, func(*sql.Row) (*IDPTempla
|
||||
AppleKeyIDCol.identifier(),
|
||||
ApplePrivateKeyCol.identifier(),
|
||||
AppleScopesCol.identifier(),
|
||||
// zitadel
|
||||
ZitadelIDCol.identifier(),
|
||||
ZitadelIssuerCol.identifier(),
|
||||
ZitadelClientIDCol.identifier(),
|
||||
ZitadelClientSecretCol.identifier(),
|
||||
ZitadelScopesCol.identifier(),
|
||||
ZitadelInstanceRolesInfoCol.identifier(),
|
||||
).From(idpTemplateTable.identifier()).
|
||||
LeftJoin(join(OAuthIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(OIDCIDCol, IDPTemplateIDCol)).
|
||||
@@ -1011,6 +1063,7 @@ func prepareIDPTemplateByIDQuery() (sq.SelectBuilder, func(*sql.Row) (*IDPTempla
|
||||
LeftJoin(join(SAMLIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(LDAPIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(AppleIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(ZitadelIDCol, IDPTemplateIDCol)).
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
func(row *sql.Row) (*IDPTemplate, error) {
|
||||
idpTemplate := new(IDPTemplate)
|
||||
@@ -1121,6 +1174,13 @@ func prepareIDPTemplateByIDQuery() (sq.SelectBuilder, func(*sql.Row) (*IDPTempla
|
||||
applePrivateKey := new(crypto.CryptoValue)
|
||||
appleScopes := database.TextArray[string]{}
|
||||
|
||||
zitadelID := sql.NullString{}
|
||||
zitadelClientID := sql.NullString{}
|
||||
zitadelClientSecret := new(crypto.CryptoValue)
|
||||
zitadelIssuer := sql.NullString{}
|
||||
zitadelScopes := database.TextArray[string]{}
|
||||
zitadelInstanceRolesInfo := database.JSONArray[idp.RolesInfo]{}
|
||||
|
||||
err := row.Scan(
|
||||
&idpTemplate.ID,
|
||||
&idpTemplate.ResourceOwner,
|
||||
@@ -1240,6 +1300,13 @@ func prepareIDPTemplateByIDQuery() (sq.SelectBuilder, func(*sql.Row) (*IDPTempla
|
||||
&appleKeyID,
|
||||
&applePrivateKey,
|
||||
&appleScopes,
|
||||
// zitadel
|
||||
&zitadelID,
|
||||
&zitadelIssuer,
|
||||
&zitadelClientID,
|
||||
&zitadelClientSecret,
|
||||
&zitadelScopes,
|
||||
&zitadelInstanceRolesInfo,
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
@@ -1392,7 +1459,16 @@ func prepareIDPTemplateByIDQuery() (sq.SelectBuilder, func(*sql.Row) (*IDPTempla
|
||||
Scopes: appleScopes,
|
||||
}
|
||||
}
|
||||
|
||||
if zitadelID.Valid {
|
||||
idpTemplate.ZitadelIDPTemplate = &ZitadelIDPTemplate{
|
||||
IDPID: zitadelID.String,
|
||||
ClientID: zitadelClientID.String,
|
||||
ClientSecret: zitadelClientSecret,
|
||||
Issuer: zitadelIssuer.String,
|
||||
Scopes: zitadelScopes,
|
||||
InstanceRolesInfo: zitadelInstanceRolesInfo,
|
||||
}
|
||||
}
|
||||
return idpTemplate, nil
|
||||
}
|
||||
}
|
||||
@@ -1518,6 +1594,13 @@ func prepareIDPTemplatesQuery() (sq.SelectBuilder, func(*sql.Rows) (*IDPTemplate
|
||||
AppleKeyIDCol.identifier(),
|
||||
ApplePrivateKeyCol.identifier(),
|
||||
AppleScopesCol.identifier(),
|
||||
// zitadel
|
||||
ZitadelIDCol.identifier(),
|
||||
ZitadelIssuerCol.identifier(),
|
||||
ZitadelClientIDCol.identifier(),
|
||||
ZitadelClientSecretCol.identifier(),
|
||||
ZitadelScopesCol.identifier(),
|
||||
ZitadelInstanceRolesInfoCol.identifier(),
|
||||
// count
|
||||
countColumn.identifier(),
|
||||
).From(idpTemplateTable.identifier()).
|
||||
@@ -1533,6 +1616,7 @@ func prepareIDPTemplatesQuery() (sq.SelectBuilder, func(*sql.Rows) (*IDPTemplate
|
||||
LeftJoin(join(SAMLIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(LDAPIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(AppleIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(ZitadelIDCol, IDPTemplateIDCol)).
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
func(rows *sql.Rows) (*IDPTemplates, error) {
|
||||
templates := make([]*IDPTemplate, 0)
|
||||
@@ -1646,6 +1730,13 @@ func prepareIDPTemplatesQuery() (sq.SelectBuilder, func(*sql.Rows) (*IDPTemplate
|
||||
applePrivateKey := new(crypto.CryptoValue)
|
||||
appleScopes := database.TextArray[string]{}
|
||||
|
||||
zitadelID := sql.NullString{}
|
||||
zitadelIssuer := sql.NullString{}
|
||||
zitadelClientID := sql.NullString{}
|
||||
zitadelClientSecret := new(crypto.CryptoValue)
|
||||
zitadelScopes := database.TextArray[string]{}
|
||||
zitadelInstanceRolesInfo := database.JSONArray[idp.RolesInfo]{}
|
||||
|
||||
err := rows.Scan(
|
||||
&idpTemplate.ID,
|
||||
&idpTemplate.ResourceOwner,
|
||||
@@ -1765,6 +1856,13 @@ func prepareIDPTemplatesQuery() (sq.SelectBuilder, func(*sql.Rows) (*IDPTemplate
|
||||
&appleKeyID,
|
||||
&applePrivateKey,
|
||||
&appleScopes,
|
||||
// zitadel
|
||||
&zitadelID,
|
||||
&zitadelIssuer,
|
||||
&zitadelClientID,
|
||||
&zitadelClientSecret,
|
||||
&zitadelScopes,
|
||||
&zitadelInstanceRolesInfo,
|
||||
&count,
|
||||
)
|
||||
|
||||
@@ -1916,6 +2014,16 @@ func prepareIDPTemplatesQuery() (sq.SelectBuilder, func(*sql.Rows) (*IDPTemplate
|
||||
Scopes: appleScopes,
|
||||
}
|
||||
}
|
||||
if zitadelID.Valid {
|
||||
idpTemplate.ZitadelIDPTemplate = &ZitadelIDPTemplate{
|
||||
IDPID: zitadelID.String,
|
||||
Issuer: zitadelIssuer.String,
|
||||
ClientID: zitadelClientID.String,
|
||||
ClientSecret: zitadelClientSecret,
|
||||
Scopes: zitadelScopes,
|
||||
InstanceRolesInfo: zitadelInstanceRolesInfo,
|
||||
}
|
||||
}
|
||||
templates = append(templates, idpTemplate)
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,14 @@ var (
|
||||
` projections.idp_templates6_apple.team_id,` +
|
||||
` projections.idp_templates6_apple.key_id,` +
|
||||
` projections.idp_templates6_apple.private_key,` +
|
||||
` projections.idp_templates6_apple.scopes` +
|
||||
` projections.idp_templates6_apple.scopes,` +
|
||||
// zitadel
|
||||
` projections.idp_templates6_zitadel.idp_id,` +
|
||||
` projections.idp_templates6_zitadel.issuer,` +
|
||||
` projections.idp_templates6_zitadel.client_id,` +
|
||||
` projections.idp_templates6_zitadel.client_secret,` +
|
||||
` projections.idp_templates6_zitadel.scopes,` +
|
||||
` projections.idp_templates6_zitadel.instance_roles_info` +
|
||||
` FROM projections.idp_templates6` +
|
||||
` LEFT JOIN projections.idp_templates6_oauth2 ON projections.idp_templates6.id = projections.idp_templates6_oauth2.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_oauth2.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_oidc ON projections.idp_templates6.id = projections.idp_templates6_oidc.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_oidc.instance_id` +
|
||||
@@ -146,7 +153,8 @@ var (
|
||||
` LEFT JOIN projections.idp_templates6_google ON projections.idp_templates6.id = projections.idp_templates6_google.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_google.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_saml ON projections.idp_templates6.id = projections.idp_templates6_saml.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_saml.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_ldap2 ON projections.idp_templates6.id = projections.idp_templates6_ldap2.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_ldap2.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_apple ON projections.idp_templates6.id = projections.idp_templates6_apple.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_apple.instance_id`
|
||||
` LEFT JOIN projections.idp_templates6_apple ON projections.idp_templates6.id = projections.idp_templates6_apple.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_apple.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_zitadel ON projections.idp_templates6.id = projections.idp_templates6_zitadel.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_zitadel.instance_id`
|
||||
idpTemplateCols = []string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
@@ -266,6 +274,13 @@ var (
|
||||
"key_id",
|
||||
"private_key",
|
||||
"scopes",
|
||||
// zitadel config
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"scopes",
|
||||
"instance_roles_info",
|
||||
}
|
||||
idpTemplatesQuery = `SELECT projections.idp_templates6.id,` +
|
||||
` projections.idp_templates6.resource_owner,` +
|
||||
@@ -385,6 +400,13 @@ var (
|
||||
` projections.idp_templates6_apple.key_id,` +
|
||||
` projections.idp_templates6_apple.private_key,` +
|
||||
` projections.idp_templates6_apple.scopes,` +
|
||||
// zitadel
|
||||
` projections.idp_templates6_zitadel.idp_id,` +
|
||||
` projections.idp_templates6_zitadel.issuer,` +
|
||||
` projections.idp_templates6_zitadel.client_id,` +
|
||||
` projections.idp_templates6_zitadel.client_secret,` +
|
||||
` projections.idp_templates6_zitadel.scopes,` +
|
||||
` projections.idp_templates6_zitadel.instance_roles_info,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.idp_templates6` +
|
||||
` LEFT JOIN projections.idp_templates6_oauth2 ON projections.idp_templates6.id = projections.idp_templates6_oauth2.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_oauth2.instance_id` +
|
||||
@@ -398,7 +420,8 @@ var (
|
||||
` LEFT JOIN projections.idp_templates6_google ON projections.idp_templates6.id = projections.idp_templates6_google.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_google.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_saml ON projections.idp_templates6.id = projections.idp_templates6_saml.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_saml.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_ldap2 ON projections.idp_templates6.id = projections.idp_templates6_ldap2.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_ldap2.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_apple ON projections.idp_templates6.id = projections.idp_templates6_apple.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_apple.instance_id`
|
||||
` LEFT JOIN projections.idp_templates6_apple ON projections.idp_templates6.id = projections.idp_templates6_apple.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_apple.instance_id` +
|
||||
` LEFT JOIN projections.idp_templates6_zitadel ON projections.idp_templates6.id = projections.idp_templates6_zitadel.idp_id AND projections.idp_templates6.instance_id = projections.idp_templates6_zitadel.instance_id`
|
||||
idpTemplatesCols = []string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
@@ -518,6 +541,14 @@ var (
|
||||
"key_id",
|
||||
"private_key",
|
||||
"scopes",
|
||||
// zitadel config
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"scopes",
|
||||
"instance_roles_info",
|
||||
// count
|
||||
"count",
|
||||
}
|
||||
)
|
||||
@@ -677,6 +708,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -834,6 +872,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -989,6 +1034,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -1143,6 +1195,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -1295,6 +1354,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -1447,6 +1513,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -1600,6 +1673,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -1752,6 +1832,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -1910,6 +1997,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -2083,6 +2177,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
"key_id",
|
||||
nil,
|
||||
database.TextArray[string]{"profile"},
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -2111,6 +2212,172 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "prepareIDPTemplateByIDQuery zitadel idp",
|
||||
prepare: prepareIDPTemplateByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(idpTemplateQuery),
|
||||
idpTemplateCols,
|
||||
[]driver.Value{
|
||||
"idp-id",
|
||||
"ro",
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211109),
|
||||
domain.IDPConfigStateActive,
|
||||
"idp-name",
|
||||
domain.IDPTypeZitadel,
|
||||
domain.IdentityProviderTypeOrg,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.AutoLinkingOptionUsername,
|
||||
// oauth
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// oidc
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// jwt
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// azure
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// github
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// github enterprise
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// gitlab
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// gitlab self hosted
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// google
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// saml
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// ldap config
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// apple
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
"idp-id",
|
||||
"issuer",
|
||||
"client_id",
|
||||
nil,
|
||||
database.TextArray[string]{"profile"},
|
||||
[]byte(`[{"organizationId":"org1","organizationDomain":"org1.com"}]`),
|
||||
},
|
||||
),
|
||||
},
|
||||
object: &IDPTemplate{
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211109,
|
||||
ResourceOwner: "ro",
|
||||
ID: "idp-id",
|
||||
State: domain.IDPStateActive,
|
||||
Name: "idp-name",
|
||||
Type: domain.IDPTypeZitadel,
|
||||
OwnerType: domain.IdentityProviderTypeOrg,
|
||||
IsCreationAllowed: true,
|
||||
IsLinkingAllowed: true,
|
||||
IsAutoCreation: true,
|
||||
IsAutoUpdate: true,
|
||||
AutoLinking: domain.AutoLinkingOptionUsername,
|
||||
ZitadelIDPTemplate: &ZitadelIDPTemplate{
|
||||
IDPID: "idp-id",
|
||||
Issuer: "issuer",
|
||||
ClientID: "client_id",
|
||||
ClientSecret: nil,
|
||||
Scopes: []string{"profile"},
|
||||
InstanceRolesInfo: []idp.RolesInfo{
|
||||
{
|
||||
OrganizationID: "org1",
|
||||
OrganizationDomain: "org1.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "prepareIDPTemplateByIDQuery no config",
|
||||
prepare: prepareIDPTemplateByIDQuery,
|
||||
@@ -2237,6 +2504,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -2419,6 +2693,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -2601,6 +2882,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -2756,6 +3044,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"idp-id-saml",
|
||||
@@ -2876,6 +3171,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"idp-id-google",
|
||||
@@ -2996,6 +3298,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"idp-id-oauth",
|
||||
@@ -3116,6 +3425,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"idp-id-oidc",
|
||||
@@ -3236,6 +3552,13 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"idp-id-jwt",
|
||||
@@ -3356,13 +3679,147 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"idp-id-zitadel",
|
||||
"ro",
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211109),
|
||||
domain.IDPConfigStateActive,
|
||||
"idp-name",
|
||||
domain.IDPTypeZitadel,
|
||||
domain.IdentityProviderTypeOrg,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.AutoLinkingOptionUsername,
|
||||
// oauth
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// oidc
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// jwt
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// azure
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// github
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// github enterprise
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// gitlab
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// gitlab self hosted
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// google
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// saml
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// ldap config
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// apple
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// zitadel
|
||||
"idp-id-zitadel",
|
||||
"issuer",
|
||||
"client_id",
|
||||
nil,
|
||||
database.TextArray[string]{"profile"},
|
||||
[]byte(`[{"organizationId":"org1","organizationDomain":"org1.com"}]`),
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
object: &IDPTemplates{
|
||||
SearchResponse: SearchResponse{
|
||||
Count: 6,
|
||||
Count: 7,
|
||||
},
|
||||
Templates: []*IDPTemplate{
|
||||
{
|
||||
@@ -3458,7 +3915,6 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
Scopes: []string{"profile"},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
@@ -3535,6 +3991,35 @@ func Test_IDPTemplateTemplatesPrepares(t *testing.T) {
|
||||
Audience: "audience",
|
||||
},
|
||||
},
|
||||
{
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211109,
|
||||
ResourceOwner: "ro",
|
||||
ID: "idp-id-zitadel",
|
||||
State: domain.IDPStateActive,
|
||||
Name: "idp-name",
|
||||
Type: domain.IDPTypeZitadel,
|
||||
OwnerType: domain.IdentityProviderTypeOrg,
|
||||
IsCreationAllowed: true,
|
||||
IsLinkingAllowed: true,
|
||||
IsAutoCreation: true,
|
||||
IsAutoUpdate: true,
|
||||
AutoLinking: domain.AutoLinkingOptionUsername,
|
||||
ZitadelIDPTemplate: &ZitadelIDPTemplate{
|
||||
IDPID: "idp-id-zitadel",
|
||||
Issuer: "issuer",
|
||||
ClientID: "client_id",
|
||||
ClientSecret: nil,
|
||||
Scopes: []string{"profile"},
|
||||
InstanceRolesInfo: []idp.RolesInfo{
|
||||
{
|
||||
OrganizationID: "org1",
|
||||
OrganizationDomain: "org1.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user