99 "strings"
1010
1111 "code.gitea.io/gitea/models/auth"
12+ "code.gitea.io/gitea/modules/util"
1213 "code.gitea.io/gitea/services/auth/source/ldap"
1314
1415 "github.com/urfave/cli/v2"
@@ -210,8 +211,8 @@ func newAuthService() *authService {
210211 }
211212}
212213
213- // parseAuthSource assigns values on authSource according to command line flags.
214- func parseAuthSource (c * cli.Context , authSource * auth.Source ) {
214+ // parseAuthSourceLdap assigns values on authSource according to command line flags.
215+ func parseAuthSourceLdap (c * cli.Context , authSource * auth.Source ) {
215216 if c .IsSet ("name" ) {
216217 authSource .Name = c .String ("name" )
217218 }
@@ -227,6 +228,7 @@ func parseAuthSource(c *cli.Context, authSource *auth.Source) {
227228 if c .IsSet ("disable-synchronize-users" ) {
228229 authSource .IsSyncEnabled = ! c .Bool ("disable-synchronize-users" )
229230 }
231+ authSource .TwoFactorPolicy = util .Iif (c .Bool ("skip-local-2fa" ), "skip" , "" )
230232}
231233
232234// parseLdapConfig assigns values on config according to command line flags.
@@ -298,9 +300,6 @@ func parseLdapConfig(c *cli.Context, config *ldap.Source) error {
298300 if c .IsSet ("allow-deactivate-all" ) {
299301 config .AllowDeactivateAll = c .Bool ("allow-deactivate-all" )
300302 }
301- if c .IsSet ("skip-local-2fa" ) {
302- config .SkipLocalTwoFA = c .Bool ("skip-local-2fa" )
303- }
304303 if c .IsSet ("enable-groups" ) {
305304 config .GroupsEnabled = c .Bool ("enable-groups" )
306305 }
@@ -376,7 +375,7 @@ func (a *authService) addLdapBindDn(c *cli.Context) error {
376375 },
377376 }
378377
379- parseAuthSource (c , authSource )
378+ parseAuthSourceLdap (c , authSource )
380379 if err := parseLdapConfig (c , authSource .Cfg .(* ldap.Source )); err != nil {
381380 return err
382381 }
@@ -398,7 +397,7 @@ func (a *authService) updateLdapBindDn(c *cli.Context) error {
398397 return err
399398 }
400399
401- parseAuthSource (c , authSource )
400+ parseAuthSourceLdap (c , authSource )
402401 if err := parseLdapConfig (c , authSource .Cfg .(* ldap.Source )); err != nil {
403402 return err
404403 }
@@ -427,7 +426,7 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
427426 },
428427 }
429428
430- parseAuthSource (c , authSource )
429+ parseAuthSourceLdap (c , authSource )
431430 if err := parseLdapConfig (c , authSource .Cfg .(* ldap.Source )); err != nil {
432431 return err
433432 }
@@ -449,7 +448,7 @@ func (a *authService) updateLdapSimpleAuth(c *cli.Context) error {
449448 return err
450449 }
451450
452- parseAuthSource (c , authSource )
451+ parseAuthSourceLdap (c , authSource )
453452 if err := parseLdapConfig (c , authSource .Cfg .(* ldap.Source )); err != nil {
454453 return err
455454 }
0 commit comments