mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fa8f191812
* feat: v2alpha user service idp endpoints * feat: v2alpha user service intent endpoints * begin idp intents (callback) * some cleanup * runnable idp authentication * cleanup * proto cleanup * retrieve idp info * improve success and failure handling * some unit tests * grpc unit tests * add permission check AddUserIDPLink * feat: v2alpha intent writemodel refactoring * feat: v2alpha intent writemodel refactoring * feat: v2alpha intent writemodel refactoring * provider from write model * fix idp type model and add integration tests * proto cleanup * fix integration test * add missing import * add more integration tests * auth url test * feat: v2alpha intent writemodel refactoring * remove unused functions * check token on RetrieveIdentityProviderInformation * feat: v2alpha intent writemodel refactoring * fix TestServer_RetrieveIdentityProviderInformation * fix test * i18n and linting * feat: v2alpha intent review changes --------- Co-authored-by: Livio Spring <livio.a@gmail.com> Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
113 lines
2.0 KiB
Go
113 lines
2.0 KiB
Go
package domain
|
|
|
|
import "github.com/zitadel/logging"
|
|
|
|
type IDPState int32
|
|
|
|
const (
|
|
IDPStateUnspecified IDPState = iota
|
|
IDPStateActive
|
|
IDPStateInactive
|
|
IDPStateRemoved
|
|
|
|
idpStateCount
|
|
)
|
|
|
|
func (s IDPState) Valid() bool {
|
|
return s >= 0 && s < idpStateCount
|
|
}
|
|
|
|
func (s IDPState) Exists() bool {
|
|
return s != IDPStateUnspecified && s != IDPStateRemoved
|
|
}
|
|
|
|
type IDPType int32
|
|
|
|
const (
|
|
IDPTypeUnspecified IDPType = iota
|
|
IDPTypeOIDC
|
|
IDPTypeJWT
|
|
IDPTypeOAuth
|
|
IDPTypeLDAP
|
|
IDPTypeAzureAD
|
|
IDPTypeGitHub
|
|
IDPTypeGitHubEnterprise
|
|
IDPTypeGitLab
|
|
IDPTypeGitLabSelfHosted
|
|
IDPTypeGoogle
|
|
)
|
|
|
|
func (t IDPType) GetCSSClass() string {
|
|
switch t {
|
|
case IDPTypeGoogle:
|
|
return "google"
|
|
case IDPTypeGitHub,
|
|
IDPTypeGitHubEnterprise:
|
|
return "github"
|
|
case IDPTypeGitLab,
|
|
IDPTypeGitLabSelfHosted:
|
|
return "gitlab"
|
|
case IDPTypeUnspecified,
|
|
IDPTypeOIDC,
|
|
IDPTypeJWT,
|
|
IDPTypeOAuth,
|
|
IDPTypeLDAP,
|
|
IDPTypeAzureAD:
|
|
fallthrough
|
|
default:
|
|
return ""
|
|
}
|
|
}
|
|
|
|
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 ""
|
|
}
|
|
}
|
|
|
|
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: ?
|
|
}
|