-
Notifications
You must be signed in to change notification settings - Fork 11
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
Added handling disallow_attester_search_for_domains OrgRule #1387
Added handling disallow_attester_search_for_domains OrgRule #1387
Conversation
9f1b659
to
8d0fe16
Compare
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.
I have a question
throw IllegalStateException("Not a valid email $emailAddr") | ||
} | ||
|
||
return !disallowedDomains.contains(userDomain) |
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.
doesn't this require sort of case-insensitive comparison?
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 realization is based on https://github.com/FlowCrypt/flowcrypt-browser/blob/48cb02a244b71a2acffbbc0fdb6ed4254baa0da3/extension/js/common/org-rules.ts#L170-L192.
Does include
mean case-insensitive comparison?
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.
In typescript we have:
public canLookupThisRecipientOnAttester = (emailAddr: string): boolean => {
....
const userDomain = Str.getDomainFromEmailAddress(emailAddr);
if (!userDomain) {
throw new Error(`Not a valid email ${emailAddr}`);
}
return !disallowedDomains.includes(userDomain);
}
and then:
public static getDomainFromEmailAddress = (emailAddr: string) => {
// todo: parseEmail()?
return emailAddr.toLowerCase().split('@')[1];
}
So function for getting domain in the typescript casts it to lowercase and then if you configure everything in lowercase, all works.
In Kotlin that doesn't happen:
// from EmailUtil.kt
fun getDomain(email: String): String {
return when {
TextUtils.isEmpty(email) -> ""
email.contains("@") -> email.substring(email.indexOf('@') + 1)
else -> ""
}
}
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.
I see. Thank you. I will fix it.
Well noticed, Ivan - thank you. |
This PR added handling disallow_attester_search_for_domains OrgRule
close #1203
Tests (delete all except exactly one):
To be filled by reviewers
I have reviewed that this PR... (tick whichever items you personally focused on during this review):