Juniper upgrade Studio standalone login/logout - #842
Conversation
OmarIthawi
left a comment
There was a problem hiding this comment.
Thanks @johnbaldwin! I've checked it quickly knowing that it's WIP.
I like that you're working on a simple implementation for this feature set.
I see some external authentication code, which is probably just leftovers from LMS views. I think we should not plan for external auth on this PR.
Please let me know whenever this is ready for review!
OmarIthawi
left a comment
There was a problem hiding this comment.
@johnbaldwin I've answered your comment and went for a quick review.
Nothing big, but mostly to reply to inline comments and suggest follow up refactoring once the form works.
There was a problem hiding this comment.
I agree! feature flags should help to preserve upstream behaviour in standalone mode.
aa79af6 to
438c083
Compare
|
@OmarIthawi Ready for review now. I did a bunch of refactoring. Code much smaller now. Also fixed the login error message so it looks as it was before |
ede8a55 to
11c4d39
Compare
There was a problem hiding this comment.
Class based views are the thing to do. Much better than function based views with conditional request.method == 'GET_ME_OUT_OF_HERE' checks
There was a problem hiding this comment.
At some point, we probably want to get this implemented with Django Forms. Did this as a quick hack to save time
There was a problem hiding this comment.
@OmarIthawi This is where all the MTE magic happens. We might want to pull this code out of './openedx/core/djangoapps/user_authn/views/login.py' and make it a Python API instead of pinky-swear private functions.
There was a problem hiding this comment.
@OmarIthawi I think we need to add a check here for authorization to be a studio author/admin
The basic workflow works. Should work well enough for staging. Absolutely needs a bunch more work for production
Refactored, simplified and cleaned up studio login code
This should be ready for staging work. Should only need the following: The login 'Sign in here' button needs to be disabled until form fields are valid (having email in the email field, some text in the password field
11c4d39 to
3cafaa6
Compare
OmarIthawi
left a comment
There was a problem hiding this comment.
I did one more review round for this PR aiming to reduce conflicts in large settings files. It with the Koa upgrade:
- We do IdP before Koa: It makes this PR easy to revert.
- We do IdP after Koa: We can do an easier merge.
Please add few basic test cases to ensure that login/logout actually works as expected for correct/incorrect passwords.
| from django.utils.decorators import method_decorator | ||
|
|
||
| from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers | ||
| from openedx.core.djangoapps.user_authn.views.login import _get_user_by_email |
There was a problem hiding this comment.
I like your suggestion. I think we should do that now, the function wasn't used outside login until now. A good step is to make a function that's more usable and discoverable by other modules:
I think for now we can do the following until we can refactor it better:
# user_authn/api.py
def get_user_from_login_request(request):
"""
Gets the email from a login POST request.
Performs needed checks and handle Multi-Tenant Emails logic.
"""
return _get_user_by_email(request)| # Can we remove this one or maybe use settings to conditionally include | ||
| url(r'', include('openedx.core.djangoapps.user_authn.urls_common')), |
There was a problem hiding this comment.
I read the module comments and I'm thinking that we probably should keep these lines as-is.
edx-platform/openedx/core/djangoapps/user_authn/urls_common.py
Lines 1 to 11 in 2827f54
| # Can we remove this one or maybe use settings to conditionally include | |
| url(r'', include('openedx.core.djangoapps.user_authn.urls_common')), | |
| url(r'', include('openedx.core.djangoapps.user_authn.urls_common')), |
There was a problem hiding this comment.
Ok, I'll remove the comment then
| # Keeping the original Juniper LMD redirect login code | ||
| # TBD if we want to conditionally include via settings so that it is | ||
| # disabled on prod | ||
| url(r'^signin_redirect_to_lms$', contentstore.views.login_redirect_to_lms, name='login_redirect_to_lms'), |
There was a problem hiding this comment.
Yup, I think we should use settings to disable the redirect view. A basic start would be:
| # Keeping the original Juniper LMD redirect login code | |
| # TBD if we want to conditionally include via settings so that it is | |
| # disabled on prod | |
| url(r'^signin_redirect_to_lms$', contentstore.views.login_redirect_to_lms, name='login_redirect_to_lms'), | |
| ( # Tahoe: Enable the Hawthorn-like Studio login form | |
| url(r'', include('cms.djangoapps.appsembler.urls')) | |
| if settings.FEATURES['TAHOE_STUDIO_LOGIN'] else | |
| url(r'^signin_redirect_to_lms$', contentstore.views.login_redirect_to_lms, name='login_redirect_to_lms') | |
| ), |
| ENTERPRISE_API_URL = LMS_INTERNAL_ROOT_URL + '/enterprise/api/v1/' | ||
| ENTERPRISE_CONSENT_API_URL = LMS_INTERNAL_ROOT_URL + '/consent/api/v1/' | ||
| ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {} | ||
|
|
There was a problem hiding this comment.
settings files are very large which creates a challenge during merge
| # Public domain name of Studio (should be resolvable from the end-user's browser) | |
| CMS_BASE = 'localhost:18010' |
| # Public domain name of Studio (should be resolvable from the end-user's browser) | ||
| CMS_BASE = 'localhost:18010' | ||
| CMS_ROOT_URL = '//localhost:18010' | ||
|
|
There was a problem hiding this comment.
To reduce conflicts: please see the lines below.
| # Public domain name of Studio (should be resolvable from the end-user's browser) | |
| CMS_BASE = 'localhost:18010' | |
| CMS_ROOT_URL = '//localhost:18010' |
| # Original 'LOGIN_URL' renamed to 'LMS_REDIRECT_LOGIN_URL' | ||
| # This is a candidate for conditional setings to switch between Studio local | ||
| # login and LMS redirection login | ||
| LMS_REDIRECT_LOGIN_URL = reverse_lazy('login_redirect_to_lms') | ||
| LOGIN_URL = reverse_lazy('login') | ||
| FRONTEND_LOGIN_URL = lambda settings: settings.CMS_ROOT_URL + '/login' |
There was a problem hiding this comment.
Reduce the change with clearer # Tahoe: comments so it's more obvious during release merge:
| # Original 'LOGIN_URL' renamed to 'LMS_REDIRECT_LOGIN_URL' | |
| # This is a candidate for conditional setings to switch between Studio local | |
| # login and LMS redirection login | |
| LMS_REDIRECT_LOGIN_URL = reverse_lazy('login_redirect_to_lms') | |
| LOGIN_URL = reverse_lazy('login') | |
| FRONTEND_LOGIN_URL = lambda settings: settings.CMS_ROOT_URL + '/login' | |
| LOGOUT_REDIRECT_URL = reverse_lazy('home') # Tahoe: To make `TAHOE_STUDIO_LOGIN` feature work | |
| LOGIN_URL = reverse_lazy('login') # Tahoe: To make `TAHOE_STUDIO_LOGIN` feature work | |
| FRONTEND_LOGIN_URL = lambda settings: settings.LMS_ROOT_URL + '/login' |
| FRONTEND_LOGOUT_URL = lambda settings: settings.CMS_ROOT_URL + '/logout/' | ||
| derived('FRONTEND_LOGOUT_URL') |
There was a problem hiding this comment.
Simplify the change with clearer comments for the release merge
| FRONTEND_LOGOUT_URL = lambda settings: settings.CMS_ROOT_URL + '/logout/' | |
| derived('FRONTEND_LOGOUT_URL') | |
| # Tahoe: in Juniper.master was `FRONTEND_LOGOUT_URL = lambda settings: settings.LMS_ROOT_URL + '/logout'` | |
| # Tahoe: in Juniper.master was `derived('FRONTEND_LOGOUT_URL')` | |
| FRONTEND_LOGOUT_URL = reverse_lazy('logout') # Tahoe: To make `TAHOE_STUDIO_LOGIN` feature work |
| LOGOUT_REDIRECT_URL = reverse_lazy('home') | ||
|
|
There was a problem hiding this comment.
Added above with # Tahoe: comments
| LOGOUT_REDIRECT_URL = reverse_lazy('home') |
| @@ -0,0 +1,50 @@ | |||
| <%namespace name='static' file='/static_content.html'/> | |||
There was a problem hiding this comment.
This could resolve the test failures.
| <%namespace name='static' file='/static_content.html'/> | |
| ## mako | |
| <%namespace name='static' file='/static_content.html'/> |
There was a problem hiding this comment.
I don't think ## mako has anything to do with test failures.
It appears to be just a Mako comment line. Perhaps it's a hint to the developers?
I see it unevenly used in edx-platform Mako templates
I don't see it mentioned anywhere as some kind of compiler hint or directive in the Mako documentation or on the web. Do you?
There was a problem hiding this comment.
I don't see it mentioned anywhere as some kind of compiler hint or directive in the Mako documentation or on the web. Do you?
Yes, it's a compiler hint that is useful in Class Based Views. Not to say that it's required.
This is just to get the tests passing. We'll follow on with adding confugration so the default state (login direct to LMS) will be back for the nominal tests
|
Closing. This PR has been superseded by #847 |
Studio local login should work now and the signin form should look like Hawthorn.
There may need to be some improvements, but I think it is good enough to get this pushed to Juniper staging
https://appsembler.atlassian.net/browse/RED-1571