mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
feat: add gitlab provider templates (#5405)
* feat(api): add google provider template * refactor reduce functions * handle removed event * linting * fix projection * feat(api): add generic oauth provider template * feat(api): add github provider templates * feat(api): add github provider templates * fixes * proto comment * fix filtering * requested changes * feat(api): add generic oauth provider template * remove wrongly committed message * increase budget for angular build * fix linting * fixes * fix merge * fix merge * fix projection * fix merge * updates from previous PRs * enable github providers in login * fix merge * fix test and add github styling in login * cleanup * feat(api): add gitlab provider templates * fix: merge * fix display of providers in login * implement gitlab in login and make prompt `select_account` optional since gitlab can't handle it * fix merge * fix merge and add tests for command side * requested changes * requested changes * Update internal/query/idp_template.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * fix merge * requested changes --------- Co-authored-by: Silvan <silvan.reusser@gmail.com>
This commit is contained in:
@@ -39,6 +39,8 @@ type IDPTemplate struct {
|
||||
*JWTIDPTemplate
|
||||
*GitHubIDPTemplate
|
||||
*GitHubEnterpriseIDPTemplate
|
||||
*GitLabIDPTemplate
|
||||
*GitLabSelfHostedIDPTemplate
|
||||
*GoogleIDPTemplate
|
||||
*LDAPIDPTemplate
|
||||
}
|
||||
@@ -92,6 +94,21 @@ type GitHubEnterpriseIDPTemplate struct {
|
||||
Scopes database.StringArray
|
||||
}
|
||||
|
||||
type GitLabIDPTemplate struct {
|
||||
IDPID string
|
||||
ClientID string
|
||||
ClientSecret *crypto.CryptoValue
|
||||
Scopes database.StringArray
|
||||
}
|
||||
|
||||
type GitLabSelfHostedIDPTemplate struct {
|
||||
IDPID string
|
||||
Issuer string
|
||||
ClientID string
|
||||
ClientSecret *crypto.CryptoValue
|
||||
Scopes database.StringArray
|
||||
}
|
||||
|
||||
type GoogleIDPTemplate struct {
|
||||
IDPID string
|
||||
ClientID string
|
||||
@@ -350,6 +367,64 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
gitlabIdpTemplateTable = table{
|
||||
name: projection.IDPTemplateGitLabTable,
|
||||
instanceIDCol: projection.GitLabInstanceIDCol,
|
||||
}
|
||||
GitLabIDCol = Column{
|
||||
name: projection.GitLabIDCol,
|
||||
table: gitlabIdpTemplateTable,
|
||||
}
|
||||
GitLabInstanceIDCol = Column{
|
||||
name: projection.GitLabInstanceIDCol,
|
||||
table: gitlabIdpTemplateTable,
|
||||
}
|
||||
GitLabClientIDCol = Column{
|
||||
name: projection.GitLabClientIDCol,
|
||||
table: gitlabIdpTemplateTable,
|
||||
}
|
||||
GitLabClientSecretCol = Column{
|
||||
name: projection.GitLabClientSecretCol,
|
||||
table: gitlabIdpTemplateTable,
|
||||
}
|
||||
GitLabScopesCol = Column{
|
||||
name: projection.GitLabScopesCol,
|
||||
table: gitlabIdpTemplateTable,
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
gitlabSelfHostedIdpTemplateTable = table{
|
||||
name: projection.IDPTemplateGitLabSelfHostedTable,
|
||||
instanceIDCol: projection.GitLabSelfHostedInstanceIDCol,
|
||||
}
|
||||
GitLabSelfHostedIDCol = Column{
|
||||
name: projection.GitLabSelfHostedIDCol,
|
||||
table: gitlabSelfHostedIdpTemplateTable,
|
||||
}
|
||||
GitLabSelfHostedInstanceIDCol = Column{
|
||||
name: projection.GitLabSelfHostedInstanceIDCol,
|
||||
table: gitlabSelfHostedIdpTemplateTable,
|
||||
}
|
||||
GitLabSelfHostedIssuerCol = Column{
|
||||
name: projection.GitLabSelfHostedIssuerCol,
|
||||
table: gitlabSelfHostedIdpTemplateTable,
|
||||
}
|
||||
GitLabSelfHostedClientIDCol = Column{
|
||||
name: projection.GitLabSelfHostedClientIDCol,
|
||||
table: gitlabSelfHostedIdpTemplateTable,
|
||||
}
|
||||
GitLabSelfHostedClientSecretCol = Column{
|
||||
name: projection.GitLabSelfHostedClientSecretCol,
|
||||
table: gitlabSelfHostedIdpTemplateTable,
|
||||
}
|
||||
GitLabSelfHostedScopesCol = Column{
|
||||
name: projection.GitLabSelfHostedScopesCol,
|
||||
table: gitlabSelfHostedIdpTemplateTable,
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
googleIdpTemplateTable = table{
|
||||
name: projection.IDPTemplateGoogleTable,
|
||||
@@ -621,6 +696,17 @@ func prepareIDPTemplateByIDQuery(ctx context.Context, db prepareDatabase) (sq.Se
|
||||
GitHubEnterpriseTokenEndpointCol.identifier(),
|
||||
GitHubEnterpriseUserEndpointCol.identifier(),
|
||||
GitHubEnterpriseScopesCol.identifier(),
|
||||
// gitlab
|
||||
GitLabIDCol.identifier(),
|
||||
GitLabClientIDCol.identifier(),
|
||||
GitLabClientSecretCol.identifier(),
|
||||
GitLabScopesCol.identifier(),
|
||||
// gitlab self hosted
|
||||
GitLabSelfHostedIDCol.identifier(),
|
||||
GitLabSelfHostedIssuerCol.identifier(),
|
||||
GitLabSelfHostedClientIDCol.identifier(),
|
||||
GitLabSelfHostedClientSecretCol.identifier(),
|
||||
GitLabSelfHostedScopesCol.identifier(),
|
||||
// google
|
||||
GoogleIDCol.identifier(),
|
||||
GoogleClientIDCol.identifier(),
|
||||
@@ -655,6 +741,8 @@ func prepareIDPTemplateByIDQuery(ctx context.Context, db prepareDatabase) (sq.Se
|
||||
LeftJoin(join(JWTIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitHubIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitHubEnterpriseIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitLabIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitLabSelfHostedIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GoogleIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(LDAPIDCol, IDPTemplateIDCol) + db.Timetravel(call.Took(ctx))).
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
@@ -697,6 +785,17 @@ func prepareIDPTemplateByIDQuery(ctx context.Context, db prepareDatabase) (sq.Se
|
||||
githubEnterpriseUserEndpoint := sql.NullString{}
|
||||
githubEnterpriseScopes := database.StringArray{}
|
||||
|
||||
gitlabID := sql.NullString{}
|
||||
gitlabClientID := sql.NullString{}
|
||||
gitlabClientSecret := new(crypto.CryptoValue)
|
||||
gitlabScopes := database.StringArray{}
|
||||
|
||||
gitlabSelfHostedID := sql.NullString{}
|
||||
gitlabSelfHostedIssuer := sql.NullString{}
|
||||
gitlabSelfHostedClientID := sql.NullString{}
|
||||
gitlabSelfHostedClientSecret := new(crypto.CryptoValue)
|
||||
gitlabSelfHostedScopes := database.StringArray{}
|
||||
|
||||
googleID := sql.NullString{}
|
||||
googleClientID := sql.NullString{}
|
||||
googleClientSecret := new(crypto.CryptoValue)
|
||||
@@ -773,6 +872,17 @@ func prepareIDPTemplateByIDQuery(ctx context.Context, db prepareDatabase) (sq.Se
|
||||
&githubEnterpriseTokenEndpoint,
|
||||
&githubEnterpriseUserEndpoint,
|
||||
&githubEnterpriseScopes,
|
||||
// gitlab
|
||||
&gitlabID,
|
||||
&gitlabClientID,
|
||||
&gitlabClientSecret,
|
||||
&gitlabScopes,
|
||||
// gitlab self hosted
|
||||
&gitlabSelfHostedID,
|
||||
&gitlabSelfHostedIssuer,
|
||||
&gitlabSelfHostedClientID,
|
||||
&gitlabSelfHostedClientSecret,
|
||||
&gitlabSelfHostedScopes,
|
||||
// google
|
||||
&googleID,
|
||||
&googleClientID,
|
||||
@@ -860,6 +970,23 @@ func prepareIDPTemplateByIDQuery(ctx context.Context, db prepareDatabase) (sq.Se
|
||||
Scopes: githubEnterpriseScopes,
|
||||
}
|
||||
}
|
||||
if gitlabID.Valid {
|
||||
idpTemplate.GitLabIDPTemplate = &GitLabIDPTemplate{
|
||||
IDPID: gitlabID.String,
|
||||
ClientID: gitlabClientID.String,
|
||||
ClientSecret: gitlabClientSecret,
|
||||
Scopes: gitlabScopes,
|
||||
}
|
||||
}
|
||||
if gitlabSelfHostedID.Valid {
|
||||
idpTemplate.GitLabSelfHostedIDPTemplate = &GitLabSelfHostedIDPTemplate{
|
||||
IDPID: gitlabSelfHostedID.String,
|
||||
Issuer: gitlabSelfHostedIssuer.String,
|
||||
ClientID: gitlabSelfHostedClientID.String,
|
||||
ClientSecret: gitlabSelfHostedClientSecret,
|
||||
Scopes: gitlabSelfHostedScopes,
|
||||
}
|
||||
}
|
||||
if googleID.Valid {
|
||||
idpTemplate.GoogleIDPTemplate = &GoogleIDPTemplate{
|
||||
IDPID: googleID.String,
|
||||
@@ -950,6 +1077,17 @@ func prepareIDPTemplatesQuery(ctx context.Context, db prepareDatabase) (sq.Selec
|
||||
GitHubEnterpriseTokenEndpointCol.identifier(),
|
||||
GitHubEnterpriseUserEndpointCol.identifier(),
|
||||
GitHubEnterpriseScopesCol.identifier(),
|
||||
// gitlab
|
||||
GitLabIDCol.identifier(),
|
||||
GitLabClientIDCol.identifier(),
|
||||
GitLabClientSecretCol.identifier(),
|
||||
GitLabScopesCol.identifier(),
|
||||
// gitlab self hosted
|
||||
GitLabSelfHostedIDCol.identifier(),
|
||||
GitLabSelfHostedIssuerCol.identifier(),
|
||||
GitLabSelfHostedClientIDCol.identifier(),
|
||||
GitLabSelfHostedClientSecretCol.identifier(),
|
||||
GitLabSelfHostedScopesCol.identifier(),
|
||||
// google
|
||||
GoogleIDCol.identifier(),
|
||||
GoogleClientIDCol.identifier(),
|
||||
@@ -985,6 +1123,8 @@ func prepareIDPTemplatesQuery(ctx context.Context, db prepareDatabase) (sq.Selec
|
||||
LeftJoin(join(JWTIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitHubIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitHubEnterpriseIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitLabIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GitLabSelfHostedIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(GoogleIDCol, IDPTemplateIDCol)).
|
||||
LeftJoin(join(LDAPIDCol, IDPTemplateIDCol) + db.Timetravel(call.Took(ctx))).
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
@@ -1030,6 +1170,17 @@ func prepareIDPTemplatesQuery(ctx context.Context, db prepareDatabase) (sq.Selec
|
||||
githubEnterpriseUserEndpoint := sql.NullString{}
|
||||
githubEnterpriseScopes := database.StringArray{}
|
||||
|
||||
gitlabID := sql.NullString{}
|
||||
gitlabClientID := sql.NullString{}
|
||||
gitlabClientSecret := new(crypto.CryptoValue)
|
||||
gitlabScopes := database.StringArray{}
|
||||
|
||||
gitlabSelfHostedID := sql.NullString{}
|
||||
gitlabSelfHostedIssuer := sql.NullString{}
|
||||
gitlabSelfHostedClientID := sql.NullString{}
|
||||
gitlabSelfHostedClientSecret := new(crypto.CryptoValue)
|
||||
gitlabSelfHostedScopes := database.StringArray{}
|
||||
|
||||
googleID := sql.NullString{}
|
||||
googleClientID := sql.NullString{}
|
||||
googleClientSecret := new(crypto.CryptoValue)
|
||||
@@ -1106,6 +1257,17 @@ func prepareIDPTemplatesQuery(ctx context.Context, db prepareDatabase) (sq.Selec
|
||||
&githubEnterpriseTokenEndpoint,
|
||||
&githubEnterpriseUserEndpoint,
|
||||
&githubEnterpriseScopes,
|
||||
// gitlab
|
||||
&gitlabID,
|
||||
&gitlabClientID,
|
||||
&gitlabClientSecret,
|
||||
&gitlabScopes,
|
||||
// gitlab self hosted
|
||||
&gitlabSelfHostedID,
|
||||
&gitlabSelfHostedIssuer,
|
||||
&gitlabSelfHostedClientID,
|
||||
&gitlabSelfHostedClientSecret,
|
||||
&gitlabSelfHostedScopes,
|
||||
// google
|
||||
&googleID,
|
||||
&googleClientID,
|
||||
@@ -1192,6 +1354,23 @@ func prepareIDPTemplatesQuery(ctx context.Context, db prepareDatabase) (sq.Selec
|
||||
Scopes: githubEnterpriseScopes,
|
||||
}
|
||||
}
|
||||
if gitlabID.Valid {
|
||||
idpTemplate.GitLabIDPTemplate = &GitLabIDPTemplate{
|
||||
IDPID: gitlabID.String,
|
||||
ClientID: gitlabClientID.String,
|
||||
ClientSecret: gitlabClientSecret,
|
||||
Scopes: gitlabScopes,
|
||||
}
|
||||
}
|
||||
if gitlabSelfHostedID.Valid {
|
||||
idpTemplate.GitLabSelfHostedIDPTemplate = &GitLabSelfHostedIDPTemplate{
|
||||
IDPID: gitlabSelfHostedID.String,
|
||||
Issuer: gitlabSelfHostedIssuer.String,
|
||||
ClientID: gitlabSelfHostedClientID.String,
|
||||
ClientSecret: gitlabSelfHostedClientSecret,
|
||||
Scopes: gitlabSelfHostedScopes,
|
||||
}
|
||||
}
|
||||
if googleID.Valid {
|
||||
idpTemplate.GoogleIDPTemplate = &GoogleIDPTemplate{
|
||||
IDPID: googleID.String,
|
||||
|
Reference in New Issue
Block a user