MCPcopy Create free account
hub / github.com/bytebase/bytebase / NewIdentityProvider

Function NewIdentityProvider

backend/plugin/idp/ldap/ldap.go:52–77  ·  view source on GitHub ↗

NewIdentityProvider initializes a new LDAP Identity Provider with the given configuration.

(config IdentityProviderConfig)

Source from the content-addressed store, hash-verified

50// NewIdentityProvider initializes a new LDAP Identity Provider with the given
51// configuration.
52func NewIdentityProvider(config IdentityProviderConfig) (*IdentityProvider, error) {
53 for v, field := range map[string]string{
54 config.Host: "host",
55 config.BindDN: "bindDn",
56 config.BindPassword: "bindPassword",
57 config.BaseDN: "baseDn",
58 config.UserFilter: "userFilter",
59 config.FieldMapping.Identifier: "fieldMapping.identifier",
60 } {
61 if v == "" {
62 return nil, errors.Errorf("the field %q is empty but required", field)
63 }
64 }
65
66 if config.Port <= 0 {
67 if config.SecurityProtocol == storepb.LDAPIdentityProviderConfig_LDAPS {
68 config.Port = 636
69 } else {
70 config.Port = 389
71 }
72 }
73
74 return &IdentityProvider{
75 config: config,
76 }, nil
77}
78
79func (p *IdentityProvider) dial() (*ldap.Conn, error) {
80 tlsConfig := &tls.Config{

Callers 4

TestIdentityProviderMethod · 0.92
TestNewIdentityProviderFunction · 0.70
TestIdentityProviderFunction · 0.70

Calls 1

ErrorfMethod · 0.80

Tested by 2

TestNewIdentityProviderFunction · 0.56
TestIdentityProviderFunction · 0.56