mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
feat(idp): provide option to auto link user (#7734)
* init auto linking * prompt handling * working * translations * console * fixes * unify * custom texts * fix tests * linting * fix check of existing user * fix bg translation * set unspecified as default in the form
This commit is contained in:
@@ -172,6 +172,7 @@ func SetLoginTextToDomain(req *admin_pb.SetCustomLoginTextsRequest) *domain.Cust
|
||||
result.RegistrationUser = text.RegistrationUserScreenTextPbToDomain(req.RegistrationUserText)
|
||||
result.ExternalRegistrationUserOverview = text.ExternalRegistrationUserOverviewScreenTextPbToDomain(req.ExternalRegistrationUserOverviewText)
|
||||
result.RegistrationOrg = text.RegistrationOrgScreenTextPbToDomain(req.RegistrationOrgText)
|
||||
result.LinkingUserPrompt = text.LinkingUserPromptScreenTextPbToDomain(req.LinkingUserPromptText)
|
||||
result.LinkingUsersDone = text.LinkingUserDoneScreenTextPbToDomain(req.LinkingUserDoneText)
|
||||
result.ExternalNotFound = text.ExternalUserNotFoundScreenTextPbToDomain(req.ExternalUserNotFoundText)
|
||||
result.LoginSuccess = text.SuccessLoginScreenTextPbToDomain(req.SuccessLoginText)
|
||||
|
@@ -1060,6 +1060,7 @@ func (s *Server) getCustomLoginTexts(ctx context.Context, org string, languages
|
||||
RegistrationUserText: text_grpc.RegistrationUserScreenTextToPb(text.RegistrationUser),
|
||||
ExternalRegistrationUserOverviewText: text_grpc.ExternalRegistrationUserOverviewScreenTextToPb(text.ExternalRegistrationUserOverview),
|
||||
RegistrationOrgText: text_grpc.RegistrationOrgScreenTextToPb(text.RegistrationOrg),
|
||||
LinkingUserPromptText: text_grpc.LinkingUserPromptScreenTextToPb(text.LinkingUserPrompt),
|
||||
LinkingUserDoneText: text_grpc.LinkingUserDoneScreenTextToPb(text.LinkingUsersDone),
|
||||
ExternalUserNotFoundText: text_grpc.ExternalUserNotFoundScreenTextToPb(text.ExternalNotFound),
|
||||
SuccessLoginText: text_grpc.SuccessLoginScreenTextToPb(text.LoginSuccess),
|
||||
|
@@ -274,6 +274,20 @@ func OptionsToCommand(options *idp_pb.Options) idp.Options {
|
||||
IsLinkingAllowed: options.IsLinkingAllowed,
|
||||
IsAutoCreation: options.IsAutoCreation,
|
||||
IsAutoUpdate: options.IsAutoUpdate,
|
||||
AutoLinkingOption: autoLinkingOptionToCommand(options.AutoLinking),
|
||||
}
|
||||
}
|
||||
|
||||
func autoLinkingOptionToCommand(linking idp_pb.AutoLinkingOption) domain.AutoLinkingOption {
|
||||
switch linking {
|
||||
case idp_pb.AutoLinkingOption_AUTO_LINKING_OPTION_USERNAME:
|
||||
return domain.AutoLinkingOptionUsername
|
||||
case idp_pb.AutoLinkingOption_AUTO_LINKING_OPTION_EMAIL:
|
||||
return domain.AutoLinkingOptionEmail
|
||||
case idp_pb.AutoLinkingOption_AUTO_LINKING_OPTION_UNSPECIFIED:
|
||||
return domain.AutoLinkingOptionUnspecified
|
||||
default:
|
||||
return domain.AutoLinkingOptionUnspecified
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,6 +412,7 @@ func configToPb(config *query.IDPTemplate) *idp_pb.ProviderConfig {
|
||||
IsCreationAllowed: config.IsCreationAllowed,
|
||||
IsAutoCreation: config.IsAutoCreation,
|
||||
IsAutoUpdate: config.IsAutoUpdate,
|
||||
AutoLinking: autoLinkingOptionToPb(config.AutoLinking),
|
||||
},
|
||||
}
|
||||
if config.OAuthIDPTemplate != nil {
|
||||
@@ -451,6 +466,19 @@ func configToPb(config *query.IDPTemplate) *idp_pb.ProviderConfig {
|
||||
return providerConfig
|
||||
}
|
||||
|
||||
func autoLinkingOptionToPb(linking domain.AutoLinkingOption) idp_pb.AutoLinkingOption {
|
||||
switch linking {
|
||||
case domain.AutoLinkingOptionUnspecified:
|
||||
return idp_pb.AutoLinkingOption_AUTO_LINKING_OPTION_UNSPECIFIED
|
||||
case domain.AutoLinkingOptionUsername:
|
||||
return idp_pb.AutoLinkingOption_AUTO_LINKING_OPTION_USERNAME
|
||||
case domain.AutoLinkingOptionEmail:
|
||||
return idp_pb.AutoLinkingOption_AUTO_LINKING_OPTION_EMAIL
|
||||
default:
|
||||
return idp_pb.AutoLinkingOption_AUTO_LINKING_OPTION_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
func oauthConfigToPb(providerConfig *idp_pb.ProviderConfig, template *query.OAuthIDPTemplate) {
|
||||
providerConfig.Config = &idp_pb.ProviderConfig_Oauth{
|
||||
Oauth: &idp_pb.OAuthConfig{
|
||||
|
@@ -171,6 +171,7 @@ func SetLoginCustomTextToDomain(req *mgmt_pb.SetCustomLoginTextsRequest) *domain
|
||||
result.RegistrationUser = text.RegistrationUserScreenTextPbToDomain(req.RegistrationUserText)
|
||||
result.ExternalRegistrationUserOverview = text.ExternalRegistrationUserOverviewScreenTextPbToDomain(req.ExternalRegistrationUserOverviewText)
|
||||
result.RegistrationOrg = text.RegistrationOrgScreenTextPbToDomain(req.RegistrationOrgText)
|
||||
result.LinkingUserPrompt = text.LinkingUserPromptScreenTextPbToDomain(req.LinkingUserPromptText)
|
||||
result.LinkingUsersDone = text.LinkingUserDoneScreenTextPbToDomain(req.LinkingUserDoneText)
|
||||
result.ExternalNotFound = text.ExternalUserNotFoundScreenTextPbToDomain(req.ExternalUserNotFoundText)
|
||||
result.LoginSuccess = text.SuccessLoginScreenTextPbToDomain(req.SuccessLoginText)
|
||||
|
@@ -64,6 +64,7 @@ func CustomLoginTextToPb(text *domain.CustomLoginText) *text_pb.LoginCustomText
|
||||
RegistrationUserText: RegistrationUserScreenTextToPb(text.RegistrationUser),
|
||||
ExternalRegistrationUserOverviewText: ExternalRegistrationUserOverviewScreenTextToPb(text.ExternalRegistrationUserOverview),
|
||||
RegistrationOrgText: RegistrationOrgScreenTextToPb(text.RegistrationOrg),
|
||||
LinkingUserPromptText: LinkingUserPromptScreenTextToPb(text.LinkingUserPrompt),
|
||||
LinkingUserDoneText: LinkingUserDoneScreenTextToPb(text.LinkingUsersDone),
|
||||
ExternalUserNotFoundText: ExternalUserNotFoundScreenTextToPb(text.ExternalNotFound),
|
||||
SuccessLoginText: SuccessLoginScreenTextToPb(text.LoginSuccess),
|
||||
@@ -422,6 +423,15 @@ func LinkingUserDoneScreenTextToPb(text domain.LinkingUserDoneScreenText) *text_
|
||||
}
|
||||
}
|
||||
|
||||
func LinkingUserPromptScreenTextToPb(text domain.LinkingUserPromptScreenText) *text_pb.LinkingUserPromptScreenText {
|
||||
return &text_pb.LinkingUserPromptScreenText{
|
||||
Title: text.Title,
|
||||
Description: text.Description,
|
||||
LinkButtonText: text.LinkButtonText,
|
||||
OtherButtonText: text.OtherButtonText,
|
||||
}
|
||||
}
|
||||
|
||||
func ExternalUserNotFoundScreenTextToPb(text domain.ExternalUserNotFoundScreenText) *text_pb.ExternalUserNotFoundScreenText {
|
||||
return &text_pb.ExternalUserNotFoundScreenText{
|
||||
Title: text.Title,
|
||||
@@ -890,6 +900,15 @@ func RegistrationOrgScreenTextPbToDomain(text *text_pb.RegistrationOrgScreenText
|
||||
}
|
||||
}
|
||||
|
||||
func LinkingUserPromptScreenTextPbToDomain(text *text_pb.LinkingUserPromptScreenText) domain.LinkingUserPromptScreenText {
|
||||
return domain.LinkingUserPromptScreenText{
|
||||
Title: text.GetTitle(),
|
||||
Description: text.GetDescription(),
|
||||
LinkButtonText: text.GetLinkButtonText(),
|
||||
OtherButtonText: text.GetOtherButtonText(),
|
||||
}
|
||||
}
|
||||
|
||||
func LinkingUserDoneScreenTextPbToDomain(text *text_pb.LinkingUserDoneScreenText) domain.LinkingUserDoneScreenText {
|
||||
if text == nil {
|
||||
return domain.LinkingUserDoneScreenText{}
|
||||
|
Reference in New Issue
Block a user