feat: allow skip of success page for native apps (#5627)

add possibility to return to callback directly after login without rendering the successful login page
This commit is contained in:
Livio Spring
2023-04-11 17:07:32 +02:00
parent 991a56341b
commit d25454b84b
32 changed files with 641 additions and 390 deletions

View File

@@ -40,6 +40,7 @@ type OIDCConfigAddedEvent struct {
IDTokenUserinfoAssertion bool `json:"idTokenUserinfoAssertion,omitempty"`
ClockSkew time.Duration `json:"clockSkew,omitempty"`
AdditionalOrigins []string `json:"additionalOrigins,omitempty"`
SkipNativeAppSuccessPage bool `json:"skipNativeAppSuccessPage,omitempty"`
}
func (e *OIDCConfigAddedEvent) Data() interface{} {
@@ -70,6 +71,7 @@ func NewOIDCConfigAddedEvent(
idTokenUserinfoAssertion bool,
clockSkew time.Duration,
additionalOrigins []string,
skipNativeAppSuccessPage bool,
) *OIDCConfigAddedEvent {
return &OIDCConfigAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
@@ -94,6 +96,7 @@ func NewOIDCConfigAddedEvent(
IDTokenUserinfoAssertion: idTokenUserinfoAssertion,
ClockSkew: clockSkew,
AdditionalOrigins: additionalOrigins,
SkipNativeAppSuccessPage: skipNativeAppSuccessPage,
}
}
@@ -179,8 +182,7 @@ func (e *OIDCConfigAddedEvent) Validate(cmd eventstore.Command) bool {
return false
}
}
return true
return e.SkipNativeAppSuccessPage == c.SkipNativeAppSuccessPage
}
func OIDCConfigAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
@@ -214,6 +216,7 @@ type OIDCConfigChangedEvent struct {
IDTokenUserinfoAssertion *bool `json:"idTokenUserinfoAssertion,omitempty"`
ClockSkew *time.Duration `json:"clockSkew,omitempty"`
AdditionalOrigins *[]string `json:"additionalOrigins,omitempty"`
SkipNativeAppSuccessPage *bool `json:"skipNativeAppSuccessPage,omitempty"`
}
func (e *OIDCConfigChangedEvent) Data() interface{} {
@@ -334,6 +337,12 @@ func ChangeAdditionalOrigins(additionalOrigins []string) func(event *OIDCConfigC
}
}
func ChangeSkipNativeAppSuccessPage(skipNativeAppSuccessPage bool) func(event *OIDCConfigChangedEvent) {
return func(e *OIDCConfigChangedEvent) {
e.SkipNativeAppSuccessPage = &skipNativeAppSuccessPage
}
}
func OIDCConfigChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
e := &OIDCConfigChangedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),