@@ -14,6 +14,7 @@ import (
1414 "text/tabwriter"
1515
1616 "code.gitea.io/gitea/models"
17+ asymkey_model "code.gitea.io/gitea/models/asymkey"
1718 "code.gitea.io/gitea/models/db"
1819 "code.gitea.io/gitea/models/login"
1920 user_model "code.gitea.io/gitea/models/user"
@@ -298,6 +299,36 @@ var (
298299 Name : "skip-local-2fa" ,
299300 Usage : "Set to true to skip local 2fa for users authenticated by this source" ,
300301 },
302+ cli.StringSliceFlag {
303+ Name : "scopes" ,
304+ Value : nil ,
305+ Usage : "Scopes to request when to authenticate against this OAuth2 source" ,
306+ },
307+ cli.StringFlag {
308+ Name : "required-claim-name" ,
309+ Value : "" ,
310+ Usage : "Claim name that has to be set to allow users to login with this source" ,
311+ },
312+ cli.StringFlag {
313+ Name : "required-claim-value" ,
314+ Value : "" ,
315+ Usage : "Claim value that has to be set to allow users to login with this source" ,
316+ },
317+ cli.StringFlag {
318+ Name : "group-claim-name" ,
319+ Value : "" ,
320+ Usage : "Claim name providing group names for this source" ,
321+ },
322+ cli.StringFlag {
323+ Name : "admin-group" ,
324+ Value : "" ,
325+ Usage : "Group Claim value for administrator users" ,
326+ },
327+ cli.StringFlag {
328+ Name : "restricted-group" ,
329+ Value : "" ,
330+ Usage : "Group Claim value for restricted users" ,
331+ },
301332 }
302333
303334 microcmdAuthUpdateOauth = cli.Command {
@@ -348,6 +379,10 @@ func runChangePassword(c *cli.Context) error {
348379 if err := initDB (ctx ); err != nil {
349380 return err
350381 }
382+ if len (c .String ("password" )) < setting .MinPasswordLength {
383+ return fmt .Errorf ("Password is not long enough. Needs to be at least %d" , setting .MinPasswordLength )
384+ }
385+
351386 if ! pwd .IsComplexEnough (c .String ("password" )) {
352387 return errors .New ("Password does not meet complexity requirements" )
353388 }
@@ -625,7 +660,7 @@ func runRegenerateKeys(_ *cli.Context) error {
625660 if err := initDB (ctx ); err != nil {
626661 return err
627662 }
628- return models .RewriteAllPublicKeys ()
663+ return asymkey_model .RewriteAllPublicKeys ()
629664}
630665
631666func parseOAuth2Config (c * cli.Context ) * oauth2.Source {
@@ -648,6 +683,12 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
648683 CustomURLMapping : customURLMapping ,
649684 IconURL : c .String ("icon-url" ),
650685 SkipLocalTwoFA : c .Bool ("skip-local-2fa" ),
686+ Scopes : c .StringSlice ("scopes" ),
687+ RequiredClaimName : c .String ("required-claim-name" ),
688+ RequiredClaimValue : c .String ("required-claim-value" ),
689+ GroupClaimName : c .String ("group-claim-name" ),
690+ AdminGroup : c .String ("admin-group" ),
691+ RestrictedGroup : c .String ("restricted-group" ),
651692 }
652693}
653694
@@ -710,6 +751,28 @@ func runUpdateOauth(c *cli.Context) error {
710751 oAuth2Config .IconURL = c .String ("icon-url" )
711752 }
712753
754+ if c .IsSet ("scopes" ) {
755+ oAuth2Config .Scopes = c .StringSlice ("scopes" )
756+ }
757+
758+ if c .IsSet ("required-claim-name" ) {
759+ oAuth2Config .RequiredClaimName = c .String ("required-claim-name" )
760+
761+ }
762+ if c .IsSet ("required-claim-value" ) {
763+ oAuth2Config .RequiredClaimValue = c .String ("required-claim-value" )
764+ }
765+
766+ if c .IsSet ("group-claim-name" ) {
767+ oAuth2Config .GroupClaimName = c .String ("group-claim-name" )
768+ }
769+ if c .IsSet ("admin-group" ) {
770+ oAuth2Config .AdminGroup = c .String ("admin-group" )
771+ }
772+ if c .IsSet ("restricted-group" ) {
773+ oAuth2Config .RestrictedGroup = c .String ("restricted-group" )
774+ }
775+
713776 // update custom URL mapping
714777 var customURLMapping = & oauth2.CustomURLMapping {}
715778
0 commit comments