-
Notifications
You must be signed in to change notification settings - Fork 2
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
skip onboarding #2067
base: main
Are you sure you want to change the base?
skip onboarding #2067
Conversation
Holding off on my review until #2061 merges since it makes setting up keycloak locally easier |
/gemini review |
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.
Code Review
This PR introduces the ability to skip onboarding for new users, redirecting them to a specified URL after email verification. The implementation appears well-structured, with added tests and configuration. However, there are a few areas where improvements can be made to enhance security and maintainability.
Summary of Findings
- Open Redirect Vulnerability: The current implementation relies on
SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS
for redirect sanitization. It's crucial to ensure that this list is comprehensive and that the sanitization logic is robust to prevent open redirect vulnerabilities. - Code Clarity and Readability: The logic for determining
allowed_hosts
inuser_onboarding
could be simplified for better readability. Consider using a more concise approach to handle the conditional addition ofrequest_host
. - Testing: The test case
test_user_onboarding_actions
could benefit from additional assertions to ensure that thesanitize_redirect
function is called with the expected arguments.
Assessment
The code changes introduce a valuable feature for skipping onboarding. While the implementation is generally sound, addressing the identified security and maintainability concerns is crucial before merging. I recommend focusing on the open redirect vulnerability and improving code clarity. Please have others review and approve this code before merging.
allowed_hosts = ( | ||
[ | ||
*allowed_hosts, | ||
request_host, | ||
] | ||
if allowed_hosts | ||
else [request_host] | ||
) |
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.
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.
Not doing this, as our automatic formatting rules override it.
netloc = urlparse(next_qs).netloc if next_qs else None | ||
expected_allowed_hosts = ( | ||
[*social_auth_allowed_redirect_hosts, "example.com"] | ||
if social_auth_allowed_redirect_hosts | ||
else ["example.com"] | ||
) |
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.
Consider adding an assertion to verify that urlparse(next_qs).netloc
is actually present in expected_allowed_hosts
before proceeding with the rest of the test. This will help ensure that the test is actually testing what it intends to test.
netloc = urlparse(next_qs).netloc if next_qs else None | |
expected_allowed_hosts = ( | |
[*social_auth_allowed_redirect_hosts, "example.com"] | |
if social_auth_allowed_redirect_hosts | |
else ["example.com"] | |
) | |
netloc = urlparse(next_qs).netloc if next_qs else None | |
expected_allowed_hosts = ( | |
[*social_auth_allowed_redirect_hosts, "example.com"] | |
if social_auth_allowed_redirect_hosts | |
else ["example.com"] | |
) | |
if netloc: | |
assert netloc in expected_allowed_hosts | |
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 also kind of a weird suggestion, as further down in the test netloc
is being used with:
expected_next = None
if is_new and not skip_onboarding:
expected_next = "http://example.com"
elif next_qs and netloc in expected_allowed_hosts:
expected_next = next_qs
The test then asserts that backend.strategy.session_set
is called to set the next
query string param with the proper value.
/gemini summary |
Summary of ChangesThis pull request introduces the ability to skip the onboarding process for new users and redirect them to a specified URL after email verification. It modifies the authentication pipeline to check for a Highlights
Changelog
Activity
|
…the redirect url if it is in SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS
fa12bf3
to
75b5972
Compare
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/6790
Description (What does it do?)
This PR adds the ability to skip onboarding when creating a new user, instead redirecting to the sanitized
next
query string param if available.How can this be tested?
.env
file, set `SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS=["google.com"]mit-learn
on this branch