-
Notifications
You must be signed in to change notification settings - Fork 27
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
🐛 Is812/email case insensitive #3953
🐛 Is812/email case insensitive #3953
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3953 +/- ##
========================================
+ Coverage 85.0% 86.2% +1.2%
========================================
Files 935 797 -138
Lines 40313 35578 -4735
Branches 848 394 -454
========================================
- Hits 34286 30687 -3599
+ Misses 5804 4782 -1022
+ Partials 223 109 -114
Flags with carried forward coverage won't be shown. Click here to find out more.
|
d1da7b4
to
6819f9c
Compare
…espov/osparc-simcore into is812/email-case-insensitive
…espov/osparc-simcore into is812/email-case-insensitive
Very nice addition, check please if test_groups.py changes really make sense? |
I tried to test 3 scenarios:
|
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.
it seems my comments did not make it through this morning. really sorry about this. now this should work. I have a few questions regarding test_groups.py syntax. we can also talk about it tomorrow.
services/web/server/tests/unit/with_dbs/03/login/test_login_auth.py
Outdated
Show resolved
Hide resolved
Code Climate has analyzed commit add93f3 and detected 0 issues on this pull request. View more on Code Climate. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
While you changes work. I am worried that in the future we might stumble upon bugs due to the different way we treat emails. We check agains the db for email [email protected]
but in a template we might have [email protected]
and this could cease some unexpected issues.
My proposal is to apply lower case as soon as the email hits one of the entry points of a service and always use it as lower case.
@@ -39,7 +39,9 @@ async def get_user_gid_from_email( | |||
) -> Optional[PositiveInt]: | |||
async with self.db_engine.connect() as conn: | |||
return await conn.scalar( | |||
sa.select([users.c.primary_gid]).where(users.c.email == user_email) | |||
sa.select([users.c.primary_gid]).where( | |||
users.c.email == user_email.lower() |
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 not what I would have expected. I would have changed the email at the point of ingress in the application. At the edge (on the ingress API route).
Doing so gives the guarantee that the email string is the same during the entire request and not treated differently in some cases.
I would track where this is coming from and change it accordingly at that entry point.
result = await conn.execute( | ||
sa.select([users]).where(users.c.email == email.lower()) | ||
) |
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 comment as above, please check the source(s) and apply lower case at the closes point of entry in the application.
@@ -24,7 +24,7 @@ async def login_granted_response( | |||
|
|||
Uses security API | |||
""" | |||
email = user["email"] | |||
email = user["email"].lower() |
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
@@ -110,7 +110,7 @@ async def login(request: web.Request): | |||
) | |||
|
|||
assert user["status"] == ACTIVE, "db corrupted. Invalid status" # nosec | |||
assert user["email"] == login_.email, "db corrupted. Invalid email" # nosec | |||
assert user["email"] == login_.email.lower(), "db corrupted. Invalid email" # nosec |
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.
And here as well I would make sure that login_.email
is already lower case when used here
if with_data.get("email"): | ||
with_data["email"] = with_data["email"].lower() |
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.
and here
if data.get("email"): | ||
data["email"] = data["email"].lower() |
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.
and here once more
What do these changes do?
Related issue/s
How to test
Checklist