feat: implement login redirect middleware [BB-5090] [OSPR-6223] - #29316
feat: implement login redirect middleware [BB-5090] [OSPR-6223]#29316Cup0fCoffee wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @Cup0fCoffee! I've created OSPR-6223 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
Implemented a new middleware, that redirects all unathorised user, that are trying to vising any page but login and register, to login page. The middleware is enabled via a ENABLE_REDIRECT_UNAUTHORISED_USERS_TO_LOGIN setting. Added the middleware and the setting to the LMS.
955cd24 to
8ae40dc
Compare
|
@Cup0fCoffee Thank you for your contribution. Is this ready for our review? |
|
Your PR has finished running tests. There were no failures. |
|
@natabene Yes. |
|
@natabene, @0x29a has discovered that the current implementation of the feature breaks the third party authentication when enabled. We have a few ideas for how to fix it, and are working on it. However, we are not confident that our implementation can be comprehensive enough to be upstreamed. If there is interest in the feature, we can discuss possible implementations and how to cover all corner cases on the forum in the future. For now this PR can be closed. |
|
@Cup0fCoffee Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This PR implements new middleware that redirects all unathenticated users to login page. It enables admins to enable the middleware through settings for LMS to prevent unathenticated users from seeing any content.
Supporting information
BB-5090
OSPR-6223
Testing instructions
make lms-upin the devstackhttp://localhost:18000/courses/(logout before that, if you're logged in) - you will be able to see the available coursesmake lms-shellin the devstack, open/edx/etc/lms.ymland under 'FEATURES' addENABLE_REDIRECT_UNATHENTICATED_USERS_TO_LOGIN: truemake lms-restart-devserverhttp://localhost:18000/courses/, you'll be redirected to login page/courses/)Other information
The middleware is implemented in the "new" style, i.e. without the use of MiddlewareMixin, to not introduce more things to refactor in the future. If there are reasons for why the MiddlewareMixin is preferred, I'll happily change the implementation to use it.