9
9
"strings"
10
10
11
11
"code.gitea.io/gitea/models"
12
- "code.gitea.io/gitea/modules /auth/ldap"
12
+ "code.gitea.io/gitea/services /auth/source /ldap"
13
13
14
14
"github.com/urfave/cli"
15
15
)
@@ -172,86 +172,86 @@ func parseLoginSource(c *cli.Context, loginSource *models.LoginSource) {
172
172
loginSource .Name = c .String ("name" )
173
173
}
174
174
if c .IsSet ("not-active" ) {
175
- loginSource .IsActived = ! c .Bool ("not-active" )
175
+ loginSource .IsActive = ! c .Bool ("not-active" )
176
176
}
177
177
if c .IsSet ("synchronize-users" ) {
178
178
loginSource .IsSyncEnabled = c .Bool ("synchronize-users" )
179
179
}
180
180
}
181
181
182
182
// parseLdapConfig assigns values on config according to command line flags.
183
- func parseLdapConfig (c * cli.Context , config * models. LDAPConfig ) error {
183
+ func parseLdapConfig (c * cli.Context , config * ldap. Source ) error {
184
184
if c .IsSet ("name" ) {
185
- config .Source . Name = c .String ("name" )
185
+ config .Name = c .String ("name" )
186
186
}
187
187
if c .IsSet ("host" ) {
188
- config .Source . Host = c .String ("host" )
188
+ config .Host = c .String ("host" )
189
189
}
190
190
if c .IsSet ("port" ) {
191
- config .Source . Port = c .Int ("port" )
191
+ config .Port = c .Int ("port" )
192
192
}
193
193
if c .IsSet ("security-protocol" ) {
194
194
p , ok := findLdapSecurityProtocolByName (c .String ("security-protocol" ))
195
195
if ! ok {
196
196
return fmt .Errorf ("Unknown security protocol name: %s" , c .String ("security-protocol" ))
197
197
}
198
- config .Source . SecurityProtocol = p
198
+ config .SecurityProtocol = p
199
199
}
200
200
if c .IsSet ("skip-tls-verify" ) {
201
- config .Source . SkipVerify = c .Bool ("skip-tls-verify" )
201
+ config .SkipVerify = c .Bool ("skip-tls-verify" )
202
202
}
203
203
if c .IsSet ("bind-dn" ) {
204
- config .Source . BindDN = c .String ("bind-dn" )
204
+ config .BindDN = c .String ("bind-dn" )
205
205
}
206
206
if c .IsSet ("user-dn" ) {
207
- config .Source . UserDN = c .String ("user-dn" )
207
+ config .UserDN = c .String ("user-dn" )
208
208
}
209
209
if c .IsSet ("bind-password" ) {
210
- config .Source . BindPassword = c .String ("bind-password" )
210
+ config .BindPassword = c .String ("bind-password" )
211
211
}
212
212
if c .IsSet ("user-search-base" ) {
213
- config .Source . UserBase = c .String ("user-search-base" )
213
+ config .UserBase = c .String ("user-search-base" )
214
214
}
215
215
if c .IsSet ("username-attribute" ) {
216
- config .Source . AttributeUsername = c .String ("username-attribute" )
216
+ config .AttributeUsername = c .String ("username-attribute" )
217
217
}
218
218
if c .IsSet ("firstname-attribute" ) {
219
- config .Source . AttributeName = c .String ("firstname-attribute" )
219
+ config .AttributeName = c .String ("firstname-attribute" )
220
220
}
221
221
if c .IsSet ("surname-attribute" ) {
222
- config .Source . AttributeSurname = c .String ("surname-attribute" )
222
+ config .AttributeSurname = c .String ("surname-attribute" )
223
223
}
224
224
if c .IsSet ("email-attribute" ) {
225
- config .Source . AttributeMail = c .String ("email-attribute" )
225
+ config .AttributeMail = c .String ("email-attribute" )
226
226
}
227
227
if c .IsSet ("attributes-in-bind" ) {
228
- config .Source . AttributesInBind = c .Bool ("attributes-in-bind" )
228
+ config .AttributesInBind = c .Bool ("attributes-in-bind" )
229
229
}
230
230
if c .IsSet ("public-ssh-key-attribute" ) {
231
- config .Source . AttributeSSHPublicKey = c .String ("public-ssh-key-attribute" )
231
+ config .AttributeSSHPublicKey = c .String ("public-ssh-key-attribute" )
232
232
}
233
233
if c .IsSet ("page-size" ) {
234
- config .Source . SearchPageSize = uint32 (c .Uint ("page-size" ))
234
+ config .SearchPageSize = uint32 (c .Uint ("page-size" ))
235
235
}
236
236
if c .IsSet ("user-filter" ) {
237
- config .Source . Filter = c .String ("user-filter" )
237
+ config .Filter = c .String ("user-filter" )
238
238
}
239
239
if c .IsSet ("admin-filter" ) {
240
- config .Source . AdminFilter = c .String ("admin-filter" )
240
+ config .AdminFilter = c .String ("admin-filter" )
241
241
}
242
242
if c .IsSet ("restricted-filter" ) {
243
- config .Source . RestrictedFilter = c .String ("restricted-filter" )
243
+ config .RestrictedFilter = c .String ("restricted-filter" )
244
244
}
245
245
if c .IsSet ("allow-deactivate-all" ) {
246
- config .Source . AllowDeactivateAll = c .Bool ("allow-deactivate-all" )
246
+ config .AllowDeactivateAll = c .Bool ("allow-deactivate-all" )
247
247
}
248
248
return nil
249
249
}
250
250
251
251
// findLdapSecurityProtocolByName finds security protocol by its name ignoring case.
252
252
// It returns the value of the security protocol and if it was found.
253
253
func findLdapSecurityProtocolByName (name string ) (ldap.SecurityProtocol , bool ) {
254
- for i , n := range models .SecurityProtocolNames {
254
+ for i , n := range ldap .SecurityProtocolNames {
255
255
if strings .EqualFold (name , n ) {
256
256
return i , true
257
257
}
@@ -289,17 +289,15 @@ func (a *authService) addLdapBindDn(c *cli.Context) error {
289
289
}
290
290
291
291
loginSource := & models.LoginSource {
292
- Type : models .LoginLDAP ,
293
- IsActived : true , // active by default
294
- Cfg : & models.LDAPConfig {
295
- Source : & ldap.Source {
296
- Enabled : true , // always true
297
- },
292
+ Type : models .LoginLDAP ,
293
+ IsActive : true , // active by default
294
+ Cfg : & ldap.Source {
295
+ Enabled : true , // always true
298
296
},
299
297
}
300
298
301
299
parseLoginSource (c , loginSource )
302
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
300
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldap. Source )); err != nil {
303
301
return err
304
302
}
305
303
@@ -318,7 +316,7 @@ func (a *authService) updateLdapBindDn(c *cli.Context) error {
318
316
}
319
317
320
318
parseLoginSource (c , loginSource )
321
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
319
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldap. Source )); err != nil {
322
320
return err
323
321
}
324
322
@@ -336,17 +334,15 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
336
334
}
337
335
338
336
loginSource := & models.LoginSource {
339
- Type : models .LoginDLDAP ,
340
- IsActived : true , // active by default
341
- Cfg : & models.LDAPConfig {
342
- Source : & ldap.Source {
343
- Enabled : true , // always true
344
- },
337
+ Type : models .LoginDLDAP ,
338
+ IsActive : true , // active by default
339
+ Cfg : & ldap.Source {
340
+ Enabled : true , // always true
345
341
},
346
342
}
347
343
348
344
parseLoginSource (c , loginSource )
349
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
345
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldap. Source )); err != nil {
350
346
return err
351
347
}
352
348
@@ -365,7 +361,7 @@ func (a *authService) updateLdapSimpleAuth(c *cli.Context) error {
365
361
}
366
362
367
363
parseLoginSource (c , loginSource )
368
- if err := parseLdapConfig (c , loginSource .LDAP ( )); err != nil {
364
+ if err := parseLdapConfig (c , loginSource .Cfg .( * ldap. Source )); err != nil {
369
365
return err
370
366
}
371
367
0 commit comments