forked from zitadel/zitadel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
idp_jwt_config.go
86 lines (74 loc) · 2.04 KB
/
idp_jwt_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
package instance
import (
"context"
"github.com/dennigogo/zitadel/internal/eventstore"
"github.com/dennigogo/zitadel/internal/eventstore/repository"
"github.com/dennigogo/zitadel/internal/repository/idpconfig"
)
const (
IDPJWTConfigAddedEventType eventstore.EventType = "iam.idp." + idpconfig.JWTConfigAddedEventType
IDPJWTConfigChangedEventType eventstore.EventType = "iam.idp." + idpconfig.JWTConfigChangedEventType
)
type IDPJWTConfigAddedEvent struct {
idpconfig.JWTConfigAddedEvent
}
func NewIDPJWTConfigAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
idpConfigID,
jwtEndpoint,
issuer,
keysEndpoint,
headerName string,
) *IDPJWTConfigAddedEvent {
return &IDPJWTConfigAddedEvent{
JWTConfigAddedEvent: *idpconfig.NewJWTConfigAddedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
IDPJWTConfigAddedEventType,
),
idpConfigID,
jwtEndpoint,
issuer,
keysEndpoint,
headerName,
),
}
}
func IDPJWTConfigAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := idpconfig.JWTConfigAddedEventMapper(event)
if err != nil {
return nil, err
}
return &IDPJWTConfigAddedEvent{JWTConfigAddedEvent: *e.(*idpconfig.JWTConfigAddedEvent)}, nil
}
type IDPJWTConfigChangedEvent struct {
idpconfig.JWTConfigChangedEvent
}
func NewIDPJWTConfigChangedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
idpConfigID string,
changes []idpconfig.JWTConfigChanges,
) (*IDPJWTConfigChangedEvent, error) {
changeEvent, err := idpconfig.NewJWTConfigChangedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
IDPJWTConfigChangedEventType),
idpConfigID,
changes,
)
if err != nil {
return nil, err
}
return &IDPJWTConfigChangedEvent{JWTConfigChangedEvent: *changeEvent}, nil
}
func IDPJWTConfigChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := idpconfig.JWTConfigChangedEventMapper(event)
if err != nil {
return nil, err
}
return &IDPJWTConfigChangedEvent{JWTConfigChangedEvent: *e.(*idpconfig.JWTConfigChangedEvent)}, nil
}