2021-01-12 11:59:51 +00:00
|
|
|
package project
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2023-12-08 14:30:55 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2021-01-12 11:59:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2024-08-28 18:19:50 +00:00
|
|
|
OIDCConfigAddedType = applicationEventTypePrefix + "config.oidc.added"
|
|
|
|
OIDCConfigChangedType = applicationEventTypePrefix + "config.oidc.changed"
|
|
|
|
OIDCConfigSecretChangedType = applicationEventTypePrefix + "config.oidc.secret.changed"
|
|
|
|
OIDCConfigSecretHashUpdatedType = applicationEventTypePrefix + "config.oidc.secret.updated"
|
2021-01-12 11:59:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type OIDCConfigAddedEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
2024-04-05 09:35:49 +00:00
|
|
|
Version domain.OIDCVersion `json:"oidcVersion,omitempty"`
|
|
|
|
AppID string `json:"appId"`
|
|
|
|
ClientID string `json:"clientId,omitempty"`
|
|
|
|
|
|
|
|
// New events only use EncodedHash. However, the ClientSecret field
|
|
|
|
// is preserved to handle events older than the switch to Passwap.
|
|
|
|
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
|
|
|
|
HashedSecret string `json:"hashedSecret,omitempty"`
|
|
|
|
|
2021-01-12 11:59:51 +00:00
|
|
|
RedirectUris []string `json:"redirectUris,omitempty"`
|
|
|
|
ResponseTypes []domain.OIDCResponseType `json:"responseTypes,omitempty"`
|
|
|
|
GrantTypes []domain.OIDCGrantType `json:"grantTypes,omitempty"`
|
|
|
|
ApplicationType domain.OIDCApplicationType `json:"applicationType,omitempty"`
|
|
|
|
AuthMethodType domain.OIDCAuthMethodType `json:"authMethodType,omitempty"`
|
|
|
|
PostLogoutRedirectUris []string `json:"postLogoutRedirectUris,omitempty"`
|
|
|
|
DevMode bool `json:"devMode,omitempty"`
|
|
|
|
AccessTokenType domain.OIDCTokenType `json:"accessTokenType,omitempty"`
|
|
|
|
AccessTokenRoleAssertion bool `json:"accessTokenRoleAssertion,omitempty"`
|
|
|
|
IDTokenRoleAssertion bool `json:"idTokenRoleAssertion,omitempty"`
|
|
|
|
IDTokenUserinfoAssertion bool `json:"idTokenUserinfoAssertion,omitempty"`
|
|
|
|
ClockSkew time.Duration `json:"clockSkew,omitempty"`
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins []string `json:"additionalOrigins,omitempty"`
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage bool `json:"skipNativeAppSuccessPage,omitempty"`
|
2021-01-12 11:59:51 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func (e *OIDCConfigAddedEvent) Payload() interface{} {
|
2021-01-12 11:59:51 +00:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func (e *OIDCConfigAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-01-21 09:49:38 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-12 11:59:51 +00:00
|
|
|
func NewOIDCConfigAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-12 11:59:51 +00:00
|
|
|
version domain.OIDCVersion,
|
|
|
|
appID string,
|
|
|
|
clientID string,
|
2024-04-05 09:35:49 +00:00
|
|
|
hashedSecret string,
|
2021-01-12 11:59:51 +00:00
|
|
|
redirectUris []string,
|
|
|
|
responseTypes []domain.OIDCResponseType,
|
|
|
|
grantTypes []domain.OIDCGrantType,
|
|
|
|
applicationType domain.OIDCApplicationType,
|
|
|
|
authMethodType domain.OIDCAuthMethodType,
|
|
|
|
postLogoutRedirectUris []string,
|
|
|
|
devMode bool,
|
|
|
|
accessTokenType domain.OIDCTokenType,
|
|
|
|
accessTokenRoleAssertion bool,
|
|
|
|
idTokenRoleAssertion bool,
|
|
|
|
idTokenUserinfoAssertion bool,
|
|
|
|
clockSkew time.Duration,
|
2021-05-19 07:17:38 +00:00
|
|
|
additionalOrigins []string,
|
2023-04-11 15:07:32 +00:00
|
|
|
skipNativeAppSuccessPage bool,
|
2021-01-12 11:59:51 +00:00
|
|
|
) *OIDCConfigAddedEvent {
|
|
|
|
return &OIDCConfigAddedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate,
|
2021-01-28 05:35:26 +00:00
|
|
|
OIDCConfigAddedType,
|
2021-01-12 11:59:51 +00:00
|
|
|
),
|
|
|
|
Version: version,
|
|
|
|
AppID: appID,
|
|
|
|
ClientID: clientID,
|
2024-04-05 09:35:49 +00:00
|
|
|
HashedSecret: hashedSecret,
|
2021-01-12 11:59:51 +00:00
|
|
|
RedirectUris: redirectUris,
|
|
|
|
ResponseTypes: responseTypes,
|
|
|
|
GrantTypes: grantTypes,
|
|
|
|
ApplicationType: applicationType,
|
|
|
|
AuthMethodType: authMethodType,
|
|
|
|
PostLogoutRedirectUris: postLogoutRedirectUris,
|
|
|
|
DevMode: devMode,
|
|
|
|
AccessTokenType: accessTokenType,
|
|
|
|
AccessTokenRoleAssertion: accessTokenRoleAssertion,
|
|
|
|
IDTokenRoleAssertion: idTokenRoleAssertion,
|
|
|
|
IDTokenUserinfoAssertion: idTokenUserinfoAssertion,
|
|
|
|
ClockSkew: clockSkew,
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins: additionalOrigins,
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage: skipNativeAppSuccessPage,
|
2021-01-12 11:59:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-12 14:20:17 +00:00
|
|
|
func (e *OIDCConfigAddedEvent) Validate(cmd eventstore.Command) bool {
|
|
|
|
c, ok := cmd.(*OIDCConfigAddedEvent)
|
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if e.Version != c.Version {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.AppID != c.AppID {
|
|
|
|
return false
|
|
|
|
}
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
if e.ClientID != c.ClientID {
|
2022-04-12 14:20:17 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.ClientSecret != c.ClientSecret {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if len(e.RedirectUris) != len(c.RedirectUris) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i, uri := range e.RedirectUris {
|
|
|
|
if uri != c.RedirectUris[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(e.ResponseTypes) != len(c.ResponseTypes) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i, typ := range e.ResponseTypes {
|
|
|
|
if typ != c.ResponseTypes[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(e.GrantTypes) != len(c.GrantTypes) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i, typ := range e.GrantTypes {
|
|
|
|
if typ != c.GrantTypes[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if e.ApplicationType != c.ApplicationType {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.AuthMethodType != c.AuthMethodType {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if len(e.PostLogoutRedirectUris) != len(c.PostLogoutRedirectUris) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i, uri := range e.PostLogoutRedirectUris {
|
|
|
|
if uri != c.PostLogoutRedirectUris[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if e.DevMode != c.DevMode {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.AccessTokenType != c.AccessTokenType {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.AccessTokenRoleAssertion != c.AccessTokenRoleAssertion {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.IDTokenRoleAssertion != c.IDTokenRoleAssertion {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.IDTokenUserinfoAssertion != c.IDTokenUserinfoAssertion {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if e.ClockSkew != c.ClockSkew {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if len(e.AdditionalOrigins) != len(c.AdditionalOrigins) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i, origin := range e.AdditionalOrigins {
|
|
|
|
if origin != c.AdditionalOrigins[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2023-04-11 15:07:32 +00:00
|
|
|
return e.SkipNativeAppSuccessPage == c.SkipNativeAppSuccessPage
|
2022-04-12 14:20:17 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func OIDCConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-01-12 11:59:51 +00:00
|
|
|
e := &OIDCConfigAddedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
err := event.Unmarshal(e)
|
2021-01-12 11:59:51 +00:00
|
|
|
if err != nil {
|
2023-12-08 14:30:55 +00:00
|
|
|
return nil, zerrors.ThrowInternal(err, "OIDC-BFd15", "unable to unmarshal oidc config")
|
2021-01-12 11:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return e, nil
|
|
|
|
}
|
2021-01-28 05:35:26 +00:00
|
|
|
|
|
|
|
type OIDCConfigChangedEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
Version *domain.OIDCVersion `json:"oidcVersion,omitempty"`
|
|
|
|
AppID string `json:"appId"`
|
|
|
|
RedirectUris *[]string `json:"redirectUris,omitempty"`
|
|
|
|
ResponseTypes *[]domain.OIDCResponseType `json:"responseTypes,omitempty"`
|
|
|
|
GrantTypes *[]domain.OIDCGrantType `json:"grantTypes,omitempty"`
|
|
|
|
ApplicationType *domain.OIDCApplicationType `json:"applicationType,omitempty"`
|
|
|
|
AuthMethodType *domain.OIDCAuthMethodType `json:"authMethodType,omitempty"`
|
|
|
|
PostLogoutRedirectUris *[]string `json:"postLogoutRedirectUris,omitempty"`
|
|
|
|
DevMode *bool `json:"devMode,omitempty"`
|
|
|
|
AccessTokenType *domain.OIDCTokenType `json:"accessTokenType,omitempty"`
|
|
|
|
AccessTokenRoleAssertion *bool `json:"accessTokenRoleAssertion,omitempty"`
|
|
|
|
IDTokenRoleAssertion *bool `json:"idTokenRoleAssertion,omitempty"`
|
|
|
|
IDTokenUserinfoAssertion *bool `json:"idTokenUserinfoAssertion,omitempty"`
|
|
|
|
ClockSkew *time.Duration `json:"clockSkew,omitempty"`
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins *[]string `json:"additionalOrigins,omitempty"`
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage *bool `json:"skipNativeAppSuccessPage,omitempty"`
|
2021-01-28 05:35:26 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func (e *OIDCConfigChangedEvent) Payload() interface{} {
|
2021-01-28 05:35:26 +00:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func (e *OIDCConfigChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-01-28 05:35:26 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewOIDCConfigChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-28 05:35:26 +00:00
|
|
|
appID string,
|
|
|
|
changes []OIDCConfigChanges,
|
|
|
|
) (*OIDCConfigChangedEvent, error) {
|
|
|
|
if len(changes) == 0 {
|
2023-12-08 14:30:55 +00:00
|
|
|
return nil, zerrors.ThrowPreconditionFailed(nil, "OIDC-i8idç", "Errors.NoChangesFound")
|
2021-01-28 05:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
changeEvent := &OIDCConfigChangedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate,
|
2021-01-28 05:35:26 +00:00
|
|
|
OIDCConfigChangedType,
|
|
|
|
),
|
|
|
|
AppID: appID,
|
|
|
|
}
|
|
|
|
for _, change := range changes {
|
|
|
|
change(changeEvent)
|
|
|
|
}
|
|
|
|
return changeEvent, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type OIDCConfigChanges func(event *OIDCConfigChangedEvent)
|
|
|
|
|
|
|
|
func ChangeVersion(version domain.OIDCVersion) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.Version = &version
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeRedirectURIs(uris []string) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.RedirectUris = &uris
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeResponseTypes(responseTypes []domain.OIDCResponseType) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.ResponseTypes = &responseTypes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeGrantTypes(grantTypes []domain.OIDCGrantType) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.GrantTypes = &grantTypes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeApplicationType(appType domain.OIDCApplicationType) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.ApplicationType = &appType
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeAuthMethodType(authMethodType domain.OIDCAuthMethodType) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.AuthMethodType = &authMethodType
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangePostLogoutRedirectURIs(logoutRedirects []string) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.PostLogoutRedirectUris = &logoutRedirects
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeDevMode(devMode bool) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.DevMode = &devMode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeAccessTokenType(accessTokenType domain.OIDCTokenType) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.AccessTokenType = &accessTokenType
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeAccessTokenRoleAssertion(accessTokenRoleAssertion bool) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.AccessTokenRoleAssertion = &accessTokenRoleAssertion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeIDTokenRoleAssertion(idTokenRoleAssertion bool) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.IDTokenRoleAssertion = &idTokenRoleAssertion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeIDTokenUserinfoAssertion(idTokenUserinfoAssertion bool) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.IDTokenUserinfoAssertion = &idTokenUserinfoAssertion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChangeClockSkew(clockSkew time.Duration) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.ClockSkew = &clockSkew
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 07:17:38 +00:00
|
|
|
func ChangeAdditionalOrigins(additionalOrigins []string) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.AdditionalOrigins = &additionalOrigins
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-11 15:07:32 +00:00
|
|
|
func ChangeSkipNativeAppSuccessPage(skipNativeAppSuccessPage bool) func(event *OIDCConfigChangedEvent) {
|
|
|
|
return func(e *OIDCConfigChangedEvent) {
|
|
|
|
e.SkipNativeAppSuccessPage = &skipNativeAppSuccessPage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func OIDCConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-01-28 05:35:26 +00:00
|
|
|
e := &OIDCConfigChangedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
err := event.Unmarshal(e)
|
2021-01-28 05:35:26 +00:00
|
|
|
if err != nil {
|
2023-12-08 14:30:55 +00:00
|
|
|
return nil, zerrors.ThrowInternal(err, "OIDC-BFd15", "unable to unmarshal oidc config")
|
2021-01-28 05:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return e, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type OIDCConfigSecretChangedEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
2024-04-05 09:35:49 +00:00
|
|
|
AppID string `json:"appId"`
|
|
|
|
|
|
|
|
// New events only use EncodedHash. However, the ClientSecret field
|
|
|
|
// is preserved to handle events older than the switch to Passwap.
|
2021-01-28 05:35:26 +00:00
|
|
|
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
|
2024-04-05 09:35:49 +00:00
|
|
|
HashedSecret string `json:"hashedSecret,omitempty"`
|
2021-01-28 05:35:26 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func (e *OIDCConfigSecretChangedEvent) Payload() interface{} {
|
2021-01-28 05:35:26 +00:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func (e *OIDCConfigSecretChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-01-28 05:35:26 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewOIDCConfigSecretChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-28 05:35:26 +00:00
|
|
|
appID string,
|
2024-04-05 09:35:49 +00:00
|
|
|
hashedSecret string,
|
2021-01-28 05:35:26 +00:00
|
|
|
) *OIDCConfigSecretChangedEvent {
|
|
|
|
return &OIDCConfigSecretChangedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate,
|
2021-01-28 05:35:26 +00:00
|
|
|
OIDCConfigSecretChangedType,
|
|
|
|
),
|
|
|
|
AppID: appID,
|
2024-04-05 09:35:49 +00:00
|
|
|
HashedSecret: hashedSecret,
|
2021-01-28 05:35:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func OIDCConfigSecretChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-01-28 05:35:26 +00:00
|
|
|
e := &OIDCConfigSecretChangedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
err := event.Unmarshal(e)
|
2021-01-28 05:35:26 +00:00
|
|
|
if err != nil {
|
2023-12-08 14:30:55 +00:00
|
|
|
return nil, zerrors.ThrowInternal(err, "OIDC-M893d", "unable to unmarshal oidc config")
|
2021-01-28 05:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return e, nil
|
|
|
|
}
|
|
|
|
|
2024-04-05 09:35:49 +00:00
|
|
|
type OIDCConfigSecretHashUpdatedEvent struct {
|
|
|
|
*eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
AppID string `json:"appId"`
|
|
|
|
HashedSecret string `json:"hashedSecret,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewOIDCConfigSecretHashUpdatedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
appID string,
|
|
|
|
hashedSecret string,
|
|
|
|
) *OIDCConfigSecretHashUpdatedEvent {
|
|
|
|
return &OIDCConfigSecretHashUpdatedEvent{
|
|
|
|
BaseEvent: eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
OIDCConfigSecretHashUpdatedType,
|
|
|
|
),
|
|
|
|
AppID: appID,
|
|
|
|
HashedSecret: hashedSecret,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *OIDCConfigSecretHashUpdatedEvent) SetBaseEvent(b *eventstore.BaseEvent) {
|
|
|
|
e.BaseEvent = b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *OIDCConfigSecretHashUpdatedEvent) Payload() interface{} {
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *OIDCConfigSecretHashUpdatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|