Skip to content
Closed
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
4 changes: 3 additions & 1 deletion internal/service/access_controls_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (rule *UserAllowedRule) Evaluate(ctx *ACLContext) Effect {
rule.Log.App.Debug().Str("username", ctx.UserContext.GetUsername()).Msg("User is in users block list, denying access")
return EffectDeny
}
return EffectAllow
}

rule.Log.App.Debug().Msg("Checking users allow list")
Expand All @@ -78,6 +77,9 @@ func (rule *UserAllowedRule) Evaluate(ctx *ACLContext) Effect {

if err != nil {
if errors.Is(err, utils.ErrFilterEmpty) {
if ctx.ACLs.Users.Block != "" {
return EffectAllow
}
return EffectAbstain
}
rule.Log.App.Warn().Err(err).Str("item", ctx.UserContext.GetUsername()).Msg("Invalid entry in users allow list")
Expand Down
45 changes: 45 additions & 0 deletions internal/service/access_controls_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,51 @@ func TestUserAllowedRule(t *testing.T) {
},
expected: EffectAllow,
},
{
name: "allows local user when username matches allow list and not block list",
ctx: &ACLContext{
ACLs: &model.App{
Users: model.AppUsers{Allow: "alice,bob", Block: "bob"},
},
UserContext: &model.UserContext{
Provider: model.ProviderLocal,
Local: &model.LocalContext{
BaseContext: model.BaseContext{Username: "alice"},
},
},
},
expected: EffectAllow,
},
{
name: "denies local user when username matches allow and block lists",
ctx: &ACLContext{
ACLs: &model.App{
Users: model.AppUsers{Allow: "alice,bob", Block: "bob"},
},
UserContext: &model.UserContext{
Provider: model.ProviderLocal,
Local: &model.LocalContext{
BaseContext: model.BaseContext{Username: "bob"},
},
},
},
expected: EffectDeny,
},
{
name: "denies local user when username matches neither allow nor block list",
ctx: &ACLContext{
ACLs: &model.App{
Users: model.AppUsers{Allow: "alice,bob", Block: "bob"},
},
UserContext: &model.UserContext{
Provider: model.ProviderLocal,
Local: &model.LocalContext{
BaseContext: model.BaseContext{Username: "charlie"},
},
},
},
expected: EffectDeny,
},
{
name: "denies when block list filter is invalid",
ctx: &ACLContext{
Expand Down
Loading