(identityProviderType storepb.IdentityProviderType, config string)
| 308 | } |
| 309 | |
| 310 | func convertIdentityProviderConfigString(identityProviderType storepb.IdentityProviderType, config string) *storepb.IdentityProviderConfig { |
| 311 | identityProviderConfig := &storepb.IdentityProviderConfig{} |
| 312 | switch identityProviderType { |
| 313 | case storepb.IdentityProviderType_OAUTH2: |
| 314 | var formattedConfig storepb.OAuth2IdentityProviderConfig |
| 315 | if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(config), &formattedConfig); err != nil { |
| 316 | return nil |
| 317 | } |
| 318 | identityProviderConfig.Config = &storepb.IdentityProviderConfig_Oauth2Config{ |
| 319 | Oauth2Config: &formattedConfig, |
| 320 | } |
| 321 | case storepb.IdentityProviderType_OIDC: |
| 322 | var formattedConfig storepb.OIDCIdentityProviderConfig |
| 323 | if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(config), &formattedConfig); err != nil { |
| 324 | return nil |
| 325 | } |
| 326 | identityProviderConfig.Config = &storepb.IdentityProviderConfig_OidcConfig{ |
| 327 | OidcConfig: &formattedConfig, |
| 328 | } |
| 329 | case storepb.IdentityProviderType_LDAP: |
| 330 | var formattedConfig storepb.LDAPIdentityProviderConfig |
| 331 | if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(config), &formattedConfig); err != nil { |
| 332 | return nil |
| 333 | } |
| 334 | identityProviderConfig.Config = &storepb.IdentityProviderConfig_LdapConfig{ |
| 335 | LdapConfig: &formattedConfig, |
| 336 | } |
| 337 | default: |
| 338 | // Return nil for unknown identity provider types |
| 339 | return nil |
| 340 | } |
| 341 | return identityProviderConfig |
| 342 | } |
no test coverage detected