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 Backlist (Blacklist) Typo #37

Merged
merged 1 commit into from
Sep 5, 2023
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
2 changes: 1 addition & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ security:
# List of switch uid to blacklist
# Block access to all switch present in this list
# You can find the uid of a switch in the log upon access
backlist:
blacklist:
- NOACCESSNOACCESSNOACCESSNOACCESSNOACCESSNOACCESSNOACCESSNOACCESS
# Endpoint to which a query will be sent to verify user/password/uid to
# Headers sent :
Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type debug struct {

type security struct {
Whitelist []string `mapstructure:"whitelist"`
Backlist []string `mapstructure:"backlist"`
Blacklist []string `mapstructure:"blacklist"`
BannedTheme []string `mapstructure:"bannedTheme"`
ForwardAuth string `mapstructure:"forwardAuth"`
}
Expand Down Expand Up @@ -298,8 +298,8 @@ func (cfg *File) IsWhitelisted(uid string) bool {
}

func (cfg *File) isInBlackList(uid string) bool {
idxBlackList := utils.Search(len(cfg.Security.Backlist), func(index int) bool {
return cfg.Security.Backlist[index] == uid
idxBlackList := utils.Search(len(cfg.Security.Blacklist), func(index int) bool {
return cfg.Security.Blacklist[index] == uid
})
return idxBlackList != -1
}
Expand Down
8 changes: 4 additions & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ var _ = Describe("Config", func() {
var blacklist = make([]string, 0)
blacklist = append(blacklist, "me")

myConfig.Security.Backlist = blacklist
myConfig.Security.Blacklist = blacklist
Expect(myConfig.IsBlacklisted("me")).To(BeTrue())
Expect(myConfig.IsWhitelisted("me")).To(BeFalse())
})
It("With a blacklist on other person", func() {
var blacklist = make([]string, 0)
blacklist = append(blacklist, "someoneElse")

myConfig.Security.Backlist = blacklist
myConfig.Security.Blacklist = blacklist
Expect(myConfig.IsBlacklisted("me")).To(BeFalse())
Expect(myConfig.IsWhitelisted("me")).To(BeTrue())
})
Expand Down Expand Up @@ -232,7 +232,7 @@ var _ = Describe("Config", func() {
var whitelist = make([]string, 0)
whitelist = append(whitelist, "someoneElse")

myConfig.Security.Backlist = blacklist
myConfig.Security.Blacklist = blacklist
myConfig.Security.Whitelist = whitelist
Expect(myConfig.IsBlacklisted("me")).To(BeTrue())
Expect(myConfig.IsWhitelisted("me")).To(BeFalse())
Expand All @@ -243,7 +243,7 @@ var _ = Describe("Config", func() {
var whitelist = make([]string, 0)
whitelist = append(whitelist, "someoneElse")

myConfig.Security.Backlist = blacklist
myConfig.Security.Blacklist = blacklist
myConfig.Security.Whitelist = whitelist
Expect(myConfig.IsBlacklisted("me")).To(BeTrue())
Expect(myConfig.IsWhitelisted("me")).To(BeFalse())
Expand Down
Loading