mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:27:42 +00:00
feat(api): add generic oauth provider template (#5260)
adds functionality to manage templates based OIDC IDPs
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
OAuthIDPAddedEventType eventstore.EventType = "org.idp.oauth.added"
|
||||
OAuthIDPChangedEventType eventstore.EventType = "org.idp.oauth.changed"
|
||||
GoogleIDPAddedEventType eventstore.EventType = "org.idp.google.added"
|
||||
GoogleIDPChangedEventType eventstore.EventType = "org.idp.google.changed"
|
||||
LDAPIDPAddedEventType eventstore.EventType = "org.idp.ldap.added"
|
||||
@@ -17,6 +19,88 @@ const (
|
||||
IDPRemovedEventType eventstore.EventType = "org.idp.removed"
|
||||
)
|
||||
|
||||
type OAuthIDPAddedEvent struct {
|
||||
idp.OAuthIDPAddedEvent
|
||||
}
|
||||
|
||||
func NewOAuthIDPAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
id,
|
||||
name,
|
||||
clientID string,
|
||||
clientSecret *crypto.CryptoValue,
|
||||
authorizationEndpoint,
|
||||
tokenEndpoint,
|
||||
userEndpoint string,
|
||||
scopes []string,
|
||||
options idp.Options,
|
||||
) *OAuthIDPAddedEvent {
|
||||
|
||||
return &OAuthIDPAddedEvent{
|
||||
OAuthIDPAddedEvent: *idp.NewOAuthIDPAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OAuthIDPAddedEventType,
|
||||
),
|
||||
id,
|
||||
name,
|
||||
clientID,
|
||||
clientSecret,
|
||||
authorizationEndpoint,
|
||||
tokenEndpoint,
|
||||
userEndpoint,
|
||||
scopes,
|
||||
options,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func OAuthIDPAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
e, err := idp.OAuthIDPAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &OAuthIDPAddedEvent{OAuthIDPAddedEvent: *e.(*idp.OAuthIDPAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type OAuthIDPChangedEvent struct {
|
||||
idp.OAuthIDPChangedEvent
|
||||
}
|
||||
|
||||
func NewOAuthIDPChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
id string,
|
||||
changes []idp.OAuthIDPChanges,
|
||||
) (*OAuthIDPChangedEvent, error) {
|
||||
|
||||
changedEvent, err := idp.NewOAuthIDPChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OAuthIDPChangedEventType,
|
||||
),
|
||||
id,
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &OAuthIDPChangedEvent{OAuthIDPChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func OAuthIDPChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
e, err := idp.OAuthIDPChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &OAuthIDPChangedEvent{OAuthIDPChangedEvent: *e.(*idp.OAuthIDPChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type GoogleIDPAddedEvent struct {
|
||||
idp.GoogleIDPAddedEvent
|
||||
}
|
||||
|
Reference in New Issue
Block a user