fix: list mapping of saml provider configuration (#6804)

Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
This commit is contained in:
Stefan Benz 2023-10-25 19:05:00 +02:00 committed by GitHub
parent 94cf30c547
commit b51ad53e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
package idp
import (
"github.com/crewjam/saml"
"google.golang.org/protobuf/types/known/durationpb"
obj_grpc "github.com/zitadel/zitadel/internal/api/grpc/object"
@ -476,6 +477,10 @@ func configToPb(config *query.IDPTemplate) *idp_pb.ProviderConfig {
appleConfigToPb(providerConfig, config.AppleIDPTemplate)
return providerConfig
}
if config.SAMLIDPTemplate != nil {
samlConfigToPb(providerConfig, config.SAMLIDPTemplate)
return providerConfig
}
return providerConfig
}
@ -637,3 +642,28 @@ func appleConfigToPb(providerConfig *idp_pb.ProviderConfig, template *query.Appl
},
}
}
func samlConfigToPb(providerConfig *idp_pb.ProviderConfig, template *query.SAMLIDPTemplate) {
providerConfig.Config = &idp_pb.ProviderConfig_Saml{
Saml: &idp_pb.SAMLConfig{
MetadataXml: template.Metadata,
Binding: bindingToPb(template.Binding),
WithSignedRequest: template.WithSignedRequest,
},
}
}
func bindingToPb(binding string) idp_pb.SAMLBinding {
switch binding {
case "":
return idp_pb.SAMLBinding_SAML_BINDING_UNSPECIFIED
case saml.HTTPPostBinding:
return idp_pb.SAMLBinding_SAML_BINDING_POST
case saml.HTTPRedirectBinding:
return idp_pb.SAMLBinding_SAML_BINDING_REDIRECT
case saml.HTTPArtifactBinding:
return idp_pb.SAMLBinding_SAML_BINDING_ARTIFACT
default:
return idp_pb.SAMLBinding_SAML_BINDING_UNSPECIFIED
}
}