2021-09-27 11:43:49 +00:00
|
|
|
package domain
|
|
|
|
|
2022-10-06 12:23:59 +00:00
|
|
|
import "strconv"
|
|
|
|
|
2021-09-27 11:43:49 +00:00
|
|
|
type FlowState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
FlowStateActive FlowState = iota
|
|
|
|
FlowStateInactive
|
|
|
|
flowStateCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s FlowState) Valid() bool {
|
|
|
|
return s >= 0 && s < flowStateCount
|
|
|
|
}
|
|
|
|
|
|
|
|
type FlowType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
FlowTypeUnspecified FlowType = iota
|
|
|
|
FlowTypeExternalAuthentication
|
2022-10-06 12:23:59 +00:00
|
|
|
FlowTypeCustomiseToken
|
2023-01-25 13:08:01 +00:00
|
|
|
FlowTypeInternalAuthentication
|
2023-08-15 15:04:45 +00:00
|
|
|
FlowTypeCustomizeSAMLResponse
|
2021-09-27 11:43:49 +00:00
|
|
|
flowTypeCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s FlowType) Valid() bool {
|
|
|
|
return s > 0 && s < flowTypeCount
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s FlowType) HasTrigger(triggerType TriggerType) bool {
|
2022-10-06 12:23:59 +00:00
|
|
|
for _, trigger := range s.TriggerTypes() {
|
|
|
|
if trigger == triggerType {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s FlowType) TriggerTypes() []TriggerType {
|
|
|
|
switch s {
|
|
|
|
case FlowTypeExternalAuthentication:
|
|
|
|
return []TriggerType{
|
|
|
|
TriggerTypePostAuthentication,
|
|
|
|
TriggerTypePreCreation,
|
|
|
|
TriggerTypePostCreation,
|
|
|
|
}
|
|
|
|
case FlowTypeCustomiseToken:
|
|
|
|
return []TriggerType{
|
|
|
|
TriggerTypePreUserinfoCreation,
|
|
|
|
TriggerTypePreAccessTokenCreation,
|
|
|
|
}
|
2023-01-25 13:08:01 +00:00
|
|
|
case FlowTypeInternalAuthentication:
|
|
|
|
return []TriggerType{
|
|
|
|
TriggerTypePostAuthentication,
|
|
|
|
TriggerTypePreCreation,
|
|
|
|
TriggerTypePostCreation,
|
|
|
|
}
|
2023-08-15 15:04:45 +00:00
|
|
|
case FlowTypeCustomizeSAMLResponse:
|
|
|
|
return []TriggerType{
|
|
|
|
TriggerTypePreSAMLResponseCreation,
|
|
|
|
}
|
2022-10-06 12:23:59 +00:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s FlowType) ID() string {
|
|
|
|
if s < 0 && s >= flowTypeCount {
|
|
|
|
return FlowTypeUnspecified.ID()
|
|
|
|
}
|
|
|
|
return strconv.Itoa(int(s))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s FlowType) LocalizationKey() string {
|
|
|
|
if s < 0 && s >= flowTypeCount {
|
|
|
|
return FlowTypeUnspecified.LocalizationKey()
|
|
|
|
}
|
|
|
|
|
|
|
|
switch s {
|
|
|
|
case FlowTypeExternalAuthentication:
|
|
|
|
return "Action.Flow.Type.ExternalAuthentication"
|
|
|
|
case FlowTypeCustomiseToken:
|
|
|
|
return "Action.Flow.Type.CustomiseToken"
|
2023-01-25 13:08:01 +00:00
|
|
|
case FlowTypeInternalAuthentication:
|
|
|
|
return "Action.Flow.Type.InternalAuthentication"
|
2023-08-15 15:04:45 +00:00
|
|
|
case FlowTypeCustomizeSAMLResponse:
|
|
|
|
return "Action.Flow.Type.CustomizeSAMLResponse"
|
2021-09-27 11:43:49 +00:00
|
|
|
default:
|
2022-10-06 12:23:59 +00:00
|
|
|
return "Action.Flow.Type.Unspecified"
|
2021-09-27 11:43:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type TriggerType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
TriggerTypeUnspecified TriggerType = iota
|
|
|
|
TriggerTypePostAuthentication
|
|
|
|
TriggerTypePreCreation
|
|
|
|
TriggerTypePostCreation
|
2022-10-06 12:23:59 +00:00
|
|
|
TriggerTypePreUserinfoCreation
|
|
|
|
TriggerTypePreAccessTokenCreation
|
2023-08-15 15:04:45 +00:00
|
|
|
TriggerTypePreSAMLResponseCreation
|
2021-09-27 11:43:49 +00:00
|
|
|
triggerTypeCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s TriggerType) Valid() bool {
|
|
|
|
return s >= 0 && s < triggerTypeCount
|
|
|
|
}
|
2022-10-06 12:23:59 +00:00
|
|
|
|
|
|
|
func (s TriggerType) ID() string {
|
|
|
|
if !s.Valid() {
|
|
|
|
return TriggerTypeUnspecified.ID()
|
|
|
|
}
|
|
|
|
return strconv.Itoa(int(s))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s TriggerType) LocalizationKey() string {
|
|
|
|
if !s.Valid() {
|
|
|
|
return FlowTypeUnspecified.LocalizationKey()
|
|
|
|
}
|
|
|
|
|
|
|
|
switch s {
|
|
|
|
case TriggerTypePostAuthentication:
|
|
|
|
return "Action.TriggerType.PostAuthentication"
|
|
|
|
case TriggerTypePreCreation:
|
|
|
|
return "Action.TriggerType.PreCreation"
|
|
|
|
case TriggerTypePostCreation:
|
|
|
|
return "Action.TriggerType.PostCreation"
|
|
|
|
case TriggerTypePreUserinfoCreation:
|
|
|
|
return "Action.TriggerType.PreUserinfoCreation"
|
|
|
|
case TriggerTypePreAccessTokenCreation:
|
|
|
|
return "Action.TriggerType.PreAccessTokenCreation"
|
2023-08-15 15:04:45 +00:00
|
|
|
case TriggerTypePreSAMLResponseCreation:
|
|
|
|
return "Action.TriggerType.PreSAMLResponseCreation"
|
2022-10-06 12:23:59 +00:00
|
|
|
default:
|
|
|
|
return "Action.TriggerType.Unspecified"
|
|
|
|
}
|
|
|
|
}
|