mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
598a4d2d4b
add basic structure and implement first providers for IDP templates to be able to manage and use them in the future
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package gitlab
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/idp"
|
|
"github.com/zitadel/zitadel/internal/idp/providers/oidc"
|
|
)
|
|
|
|
const (
|
|
issuer = "https://gitlab.com"
|
|
name = "GitLab"
|
|
)
|
|
|
|
var _ idp.Provider = (*Provider)(nil)
|
|
|
|
// Provider is the [idp.Provider] implementation for Gitlab
|
|
type Provider struct {
|
|
*oidc.Provider
|
|
}
|
|
|
|
// New creates a GitLab.com provider using the [oidc.Provider] (OIDC generic provider)
|
|
func New(clientID, clientSecret, redirectURI string, options ...oidc.ProviderOpts) (*Provider, error) {
|
|
return NewCustomIssuer(name, issuer, clientID, clientSecret, redirectURI, options...)
|
|
}
|
|
|
|
// NewCustomIssuer creates a GitLab provider using the [oidc.Provider] (OIDC generic provider)
|
|
// with a custom issuer for self-managed instances
|
|
func NewCustomIssuer(name, issuer, clientID, clientSecret, redirectURI string, options ...oidc.ProviderOpts) (*Provider, error) {
|
|
rp, err := oidc.New(name, issuer, clientID, clientSecret, redirectURI, oidc.DefaultMapper, options...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &Provider{
|
|
Provider: rp,
|
|
}, nil
|
|
}
|