2023-02-15 08:14:59 +00:00
|
|
|
package domain
|
|
|
|
|
2023-05-11 09:23:40 +00:00
|
|
|
import "github.com/zitadel/logging"
|
|
|
|
|
2023-02-15 08:14:59 +00:00
|
|
|
type IDPState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPStateUnspecified IDPState = iota
|
|
|
|
IDPStateActive
|
|
|
|
IDPStateInactive
|
|
|
|
IDPStateRemoved
|
2023-06-07 22:50:53 +00:00
|
|
|
IDPStateMigrated
|
2023-02-15 08:14:59 +00:00
|
|
|
|
|
|
|
idpStateCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s IDPState) Valid() bool {
|
|
|
|
return s >= 0 && s < idpStateCount
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s IDPState) Exists() bool {
|
2023-06-07 22:50:53 +00:00
|
|
|
return s != IDPStateUnspecified && s != IDPStateRemoved && s != IDPStateMigrated
|
2023-02-15 08:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type IDPType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPTypeUnspecified IDPType = iota
|
|
|
|
IDPTypeOIDC
|
|
|
|
IDPTypeJWT
|
|
|
|
IDPTypeOAuth
|
|
|
|
IDPTypeLDAP
|
|
|
|
IDPTypeAzureAD
|
|
|
|
IDPTypeGitHub
|
2023-03-08 10:17:28 +00:00
|
|
|
IDPTypeGitHubEnterprise
|
2023-02-15 08:14:59 +00:00
|
|
|
IDPTypeGitLab
|
|
|
|
IDPTypeGitLabSelfHosted
|
|
|
|
IDPTypeGoogle
|
|
|
|
)
|
2023-02-28 20:20:58 +00:00
|
|
|
|
|
|
|
func (t IDPType) GetCSSClass() string {
|
2023-03-13 16:34:29 +00:00
|
|
|
switch t {
|
2023-02-28 20:20:58 +00:00
|
|
|
case IDPTypeGoogle:
|
|
|
|
return "google"
|
2023-03-08 10:17:28 +00:00
|
|
|
case IDPTypeGitHub,
|
|
|
|
IDPTypeGitHubEnterprise:
|
|
|
|
return "github"
|
2023-03-13 16:34:29 +00:00
|
|
|
case IDPTypeGitLab,
|
|
|
|
IDPTypeGitLabSelfHosted:
|
|
|
|
return "gitlab"
|
|
|
|
case IDPTypeUnspecified,
|
|
|
|
IDPTypeOIDC,
|
|
|
|
IDPTypeJWT,
|
|
|
|
IDPTypeOAuth,
|
|
|
|
IDPTypeLDAP,
|
|
|
|
IDPTypeAzureAD:
|
|
|
|
fallthrough
|
2023-02-28 20:20:58 +00:00
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2023-05-11 09:23:40 +00:00
|
|
|
|
|
|
|
func IDPName(name string, idpType IDPType) string {
|
|
|
|
if name != "" {
|
|
|
|
return name
|
|
|
|
}
|
|
|
|
return idpType.DisplayName()
|
|
|
|
}
|
|
|
|
|
|
|
|
// DisplayName returns the name or a default
|
|
|
|
// to be used when always a name must be displayed (e.g. login)
|
|
|
|
func (t IDPType) DisplayName() string {
|
|
|
|
switch t {
|
|
|
|
case IDPTypeGitHub:
|
|
|
|
return "GitHub"
|
|
|
|
case IDPTypeGitLab:
|
|
|
|
return "GitLab"
|
|
|
|
case IDPTypeGoogle:
|
|
|
|
return "Google"
|
|
|
|
case IDPTypeUnspecified,
|
|
|
|
IDPTypeOIDC,
|
|
|
|
IDPTypeJWT,
|
|
|
|
IDPTypeOAuth,
|
|
|
|
IDPTypeLDAP,
|
|
|
|
IDPTypeAzureAD,
|
|
|
|
IDPTypeGitHubEnterprise,
|
|
|
|
IDPTypeGitLabSelfHosted:
|
|
|
|
fallthrough
|
|
|
|
default:
|
|
|
|
// we should never get here, so log it
|
|
|
|
logging.Errorf("name of provider (type %d) is empty", t)
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2023-05-24 18:29:58 +00:00
|
|
|
|
|
|
|
type IDPIntentState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPIntentStateUnspecified IDPIntentState = iota
|
|
|
|
IDPIntentStateStarted
|
|
|
|
IDPIntentStateSucceeded
|
|
|
|
IDPIntentStateFailed
|
|
|
|
|
|
|
|
idpIntentStateCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s IDPIntentState) Valid() bool {
|
|
|
|
return s >= 0 && s < idpIntentStateCount
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s IDPIntentState) Exists() bool {
|
|
|
|
return s != IDPIntentStateUnspecified && s != IDPIntentStateFailed //TODO: ?
|
|
|
|
}
|