forked from zitadel/zitadel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
idp_oidc_config.go
97 lines (84 loc) · 2.37 KB
/
idp_oidc_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package instance
import (
"context"
"github.com/dennigogo/zitadel/internal/eventstore"
"github.com/dennigogo/zitadel/internal/crypto"
"github.com/dennigogo/zitadel/internal/domain"
"github.com/dennigogo/zitadel/internal/eventstore/repository"
"github.com/dennigogo/zitadel/internal/repository/idpconfig"
)
const (
IDPOIDCConfigAddedEventType eventstore.EventType = "iam.idp." + idpconfig.OIDCConfigAddedEventType
IDPOIDCConfigChangedEventType eventstore.EventType = "iam.idp." + idpconfig.OIDCConfigChangedEventType
)
type IDPOIDCConfigAddedEvent struct {
idpconfig.OIDCConfigAddedEvent
}
func NewIDPOIDCConfigAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
clientID,
idpConfigID,
issuer,
authorizationEndpoint,
tokenEndpoint string,
clientSecret *crypto.CryptoValue,
idpDisplayNameMapping,
userNameMapping domain.OIDCMappingField,
scopes ...string,
) *IDPOIDCConfigAddedEvent {
return &IDPOIDCConfigAddedEvent{
OIDCConfigAddedEvent: *idpconfig.NewOIDCConfigAddedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
IDPOIDCConfigAddedEventType,
),
clientID,
idpConfigID,
issuer,
authorizationEndpoint,
tokenEndpoint,
clientSecret,
idpDisplayNameMapping,
userNameMapping,
scopes...,
),
}
}
func IDPOIDCConfigAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := idpconfig.OIDCConfigAddedEventMapper(event)
if err != nil {
return nil, err
}
return &IDPOIDCConfigAddedEvent{OIDCConfigAddedEvent: *e.(*idpconfig.OIDCConfigAddedEvent)}, nil
}
type IDPOIDCConfigChangedEvent struct {
idpconfig.OIDCConfigChangedEvent
}
func NewIDPOIDCConfigChangedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
idpConfigID string,
changes []idpconfig.OIDCConfigChanges,
) (*IDPOIDCConfigChangedEvent, error) {
changeEvent, err := idpconfig.NewOIDCConfigChangedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
IDPOIDCConfigChangedEventType),
idpConfigID,
changes,
)
if err != nil {
return nil, err
}
return &IDPOIDCConfigChangedEvent{OIDCConfigChangedEvent: *changeEvent}, nil
}
func IDPOIDCConfigChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := idpconfig.OIDCConfigChangedEventMapper(event)
if err != nil {
return nil, err
}
return &IDPOIDCConfigChangedEvent{OIDCConfigChangedEvent: *e.(*idpconfig.OIDCConfigChangedEvent)}, nil
}