@@ -10,6 +10,7 @@ import (
10
10
11
11
"code.gitea.io/gitea/models"
12
12
"code.gitea.io/gitea/modules/auth/ldap"
13
+ ldapService "code.gitea.io/gitea/services/auth/source/ldap"
13
14
14
15
"github.com/urfave/cli"
15
16
)
@@ -180,7 +181,7 @@ func parseLoginSource(c *cli.Context, loginSource *models.LoginSource) {
180
181
}
181
182
182
183
// parseLdapConfig assigns values on config according to command line flags.
183
- func parseLdapConfig (c * cli.Context , config * models. LDAPConfig ) error {
184
+ func parseLdapConfig (c * cli.Context , config * ldapService. Source ) error {
184
185
if c .IsSet ("name" ) {
185
186
config .Source .Name = c .String ("name" )
186
187
}
@@ -251,7 +252,7 @@ func parseLdapConfig(c *cli.Context, config *models.LDAPConfig) error {
251
252
// findLdapSecurityProtocolByName finds security protocol by its name ignoring case.
252
253
// It returns the value of the security protocol and if it was found.
253
254
func findLdapSecurityProtocolByName (name string ) (ldap.SecurityProtocol , bool ) {
254
- for i , n := range models .SecurityProtocolNames {
255
+ for i , n := range ldap .SecurityProtocolNames {
255
256
if strings .EqualFold (name , n ) {
256
257
return i , true
257
258
}
@@ -291,15 +292,15 @@ func (a *authService) addLdapBindDn(c *cli.Context) error {
291
292
loginSource := & models.LoginSource {
292
293
Type : models .LoginLDAP ,
293
294
IsActived : true , // active by default
294
- Cfg : & models. LDAPConfig {
295
+ Cfg : & ldapService. Source {
295
296
Source : & ldap.Source {
296
297
Enabled : true , // always true
297
298
},
298
299
},
299
300
}
300
301
301
302
parseLoginSource (c , loginSource )
302
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
303
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldapService. Source )); err != nil {
303
304
return err
304
305
}
305
306
@@ -318,7 +319,7 @@ func (a *authService) updateLdapBindDn(c *cli.Context) error {
318
319
}
319
320
320
321
parseLoginSource (c , loginSource )
321
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
322
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldapService. Source )); err != nil {
322
323
return err
323
324
}
324
325
@@ -338,15 +339,15 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
338
339
loginSource := & models.LoginSource {
339
340
Type : models .LoginDLDAP ,
340
341
IsActived : true , // active by default
341
- Cfg : & models. LDAPConfig {
342
+ Cfg : & ldapService. Source {
342
343
Source : & ldap.Source {
343
344
Enabled : true , // always true
344
345
},
345
346
},
346
347
}
347
348
348
349
parseLoginSource (c , loginSource )
349
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
350
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldapService. Source )); err != nil {
350
351
return err
351
352
}
352
353
@@ -365,7 +366,7 @@ func (a *authService) updateLdapSimpleAuth(c *cli.Context) error {
365
366
}
366
367
367
368
parseLoginSource (c , loginSource )
368
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
369
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldapService. Source )); err != nil {
369
370
return err
370
371
}
371
372
0 commit comments