-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Allow to override domains and whitelist in rules #63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is brilliant, if you could address the points in this review then LGTM
found := false | ||
for _, whitelist := range whitelist { | ||
if email == whitelist { | ||
found = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is now a separate function we don't need the temporary found
variable and this can just return true here
} | ||
for _, domain := range domains { | ||
if domain == parts[1] { | ||
found = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this can just return here
} | ||
} | ||
|
||
_, ruleExists := config.Rules[rule] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the following code shorter, could you rename the function parameter to ruleName
and then assign the first return argument of this function into a variable rule
:
rule, ruleExists := config.Rules[ruleName]
|
||
_, ruleExists := config.Rules[rule] | ||
if ruleExists && len(config.Rules[rule].Whitelist) > 0 { | ||
found = ValidateWhitelist(email, config.Rules[rule].Whitelist) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On reflection, we don't actually need the found
variable, so every branch in this function can just directly return
Would this permit something like this :
So mail1 could access every domains, mail2 domain2 and mail3 domain3 ? |
@thomseddon, @mathcantin: Has this change been obsoleted by work elsewhere? #94 mentions it, but it doesn't look like a replacement. I'm happy to make the changes needed to get this merged in otherwise |
…n#63, respecting the matchWhitelistOrDomain flag
Builds on thomseddon#63, adding support for the matchWhitelistOrDomain flag
…mseddon#63, adding support for the matchWhitelistOrDomain flag
Hoping to merge this in #169 |
Allow to override the global configuration domains and whitelist in the rules.
If whitelist or domains are specified in the rule this override the global configurations (not merged).
The new priority for auth is
whitelist in rule
>domains in rule
>config whitelist
>global domains
.Note, it's my first attempt of go.