Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove default group #5956

Merged
merged 3 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions engine/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ type Configuration struct {
InsecureSkipVerifyTLS bool `toml:"insecureSkipVerifyTLS" json:"insecureSkipVerifyTLS" default:"false"`
} `toml:"internalServiceMesh" json:"internalServiceMesh"`
Auth struct {
TokenDefaultDuration int64 `toml:"tokenDefaultDuration" default:"30" comment:"The default duration of a token (in days)" json:"tokenDefaultDuration"`
TokenOverlapDefaultDuration string `toml:"tokenOverlapDefaultDuration" default:"24h" comment:"The default overlap duration when a token is regen" json:"tokenOverlapDefaultDuration"`
DefaultGroup string `toml:"defaultGroup" default:"" comment:"The default group is the group in which every new user will be granted at signup" json:"defaultGroup"`
RSAPrivateKey string `toml:"rsaPrivateKey" default:"" comment:"The RSA Private Key used to sign and verify the JWT Tokens issued by the API \nThis is mandatory." json:"-"`
LDAP struct {
TokenDefaultDuration int64 `toml:"tokenDefaultDuration" default:"30" comment:"The default duration of a token (in days)" json:"tokenDefaultDuration"`
TokenOverlapDefaultDuration string `toml:"tokenOverlapDefaultDuration" default:"24h" comment:"The default overlap duration when a token is regen" json:"tokenOverlapDefaultDuration"`
DefaultGroup string `toml:"defaultGroup" default:"" comment:"The default group is the group in which every new user will be granted at signup" json:"defaultGroup"`
DisableAddUserInDefaultGroup bool `toml:"disableAddUserInDefaultGroup" default:"false" comment:"If false, user are automatically added in the default group" json:"disableAddUserInDefaultGroup"`
RSAPrivateKey string `toml:"rsaPrivateKey" default:"" comment:"The RSA Private Key used to sign and verify the JWT Tokens issued by the API \nThis is mandatory." json:"-"`
LDAP struct {
Enabled bool `toml:"enabled" default:"false" json:"enabled"`
SignupDisabled bool `toml:"signupDisabled" default:"false" json:"signupDisabled"`
Host string `toml:"host" json:"host"`
Expand Down
13 changes: 8 additions & 5 deletions engine/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ func (api *API) postAuthSigninHandler() service.Handler {
return err
}
}
if err := group.CheckUserInDefaultGroup(ctx, tx, u.ID); err != nil {
return err
if !api.Config.Auth.DisableAddUserInDefaultGroup {
if err := group.CheckUserInDefaultGroup(ctx, tx, u.ID); err != nil {
return err
}
}
} else {
// Check if a user already exists for external username
Expand Down Expand Up @@ -238,10 +240,11 @@ func (api *API) postAuthSigninHandler() service.Handler {
return err
}

if err := group.CheckUserInDefaultGroup(ctx, tx, u.ID); err != nil {
return err
if !api.Config.Auth.DisableAddUserInDefaultGroup {
if err := group.CheckUserInDefaultGroup(ctx, tx, u.ID); err != nil {
return err
}
}

signupDone = true
}
}
Expand Down
6 changes: 4 additions & 2 deletions engine/api/auth_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,10 @@ func (api *API) postAuthLocalVerifyHandler() service.Handler {
return err
}

if err := group.CheckUserInDefaultGroup(ctx, tx, newUser.ID); err != nil {
return err
if !api.Config.Auth.DisableAddUserInDefaultGroup {
if err := group.CheckUserInDefaultGroup(ctx, tx, newUser.ID); err != nil {
return err
}
}

// Create new local consumer for new user, set this consumer as pending validation
Expand Down