Skip to content
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

Convert session and cookie management to Laravel #9566

Closed
asmecher opened this issue Dec 8, 2023 · 10 comments
Closed

Convert session and cookie management to Laravel #9566

asmecher opened this issue Dec 8, 2023 · 10 comments
Assignees
Labels
Enhancement:2:Moderate A new feature or improvement that can be implemented in less than 4 weeks.
Milestone

Comments

@asmecher
Copy link
Member

asmecher commented Dec 8, 2023

Describe the bug
In preparation for work on OAuth/SSO, convert the underlying aspects of OJS/OMP/OPS from bespoke implementations to Laravel's toolset.

It is unclear how much of this can be done without needing to convert major aspects of the stack, e.g. authorization and request handling; this work should stop short of a major intervention for the moment.

Opportunities:

  • Replace SessionManager with SessionServiceProvider / session()
  • Replace Session/SessionDAO with Eloquent-based implementation (shipped with Laravel, I think)
  • Replace cookie implementation with CookieManager
  • Add a UserProvider implementation serving users to Laravel from current EntityDAO user implementation
  • Move CSRF token generation to Laravel (replacing homebrew implementation)

Pitfalls:

  • May need to tangle with lib/vendor/laravel/framework/src/Illuminate/Session/Middleware/* to get sessions to work properly. Not sure how deep that rabbit-hole goes yet.

PRs
pkp-lib --> #9596
ojs --> pkp/ojs#4132
ops --> pkp/ops#646
omp --> pkp/omp#1531
orcidProfile --> pkp/orcidProfile#313

@asmecher
Copy link
Member Author

asmecher commented Dec 8, 2023

I've experimented with this but think the next step is to work with the session middleware. Calling in @touhidurabir for a look!

Draft PRs (very much WIP):

To even start getting these working it's necessary to replace the sessions table with the new schema by dropping the current table and running the new migration (lib/pkp/classes/migration/install/SessionsMigration.php).

touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 4, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 4, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 4, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 4, 2024
@touhidurabir
Copy link
Member

@asmecher Draft PR
pkp-lib --> #9596
ojs --> pkp/ojs#4132

Login/Logout works fine and can access the app . Still need a lot of work on remember me, password update/reset, email/username update test, Login as other user etc . Also had to override few of laravel core classes .

touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 4, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 4, 2024
@touhidurabir touhidurabir self-assigned this Jan 8, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 15, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 15, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 15, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 15, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 15, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 22, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 22, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 22, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 28, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 28, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 28, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Jan 28, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Jan 28, 2024
@touhidurabir
Copy link
Member

@asmecher please review the draft PR at

pkp-lib --> #9596
ojs --> pkp/ojs#4132

pretty much all done except few more clean up and Sign In As functionality .

@jonasraoni
Copy link
Contributor

jonasraoni commented Jan 28, 2024

@touhidurabir you've mentioned there was something not working very well, but I guess it's solved by now, right? Or do you still need some ideas?

@touhidurabir
Copy link
Member

@jonasraoni the part I was struggling with was the session auto regeneration part and it has been resolved . Thanks for taking time to look into it.

@jonasraoni jonasraoni added the Enhancement:2:Moderate A new feature or improvement that can be implemented in less than 4 weeks. label Jan 31, 2024
touhidurabir added a commit to touhidurabir/pkp-lib that referenced this issue Feb 7, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ojs that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/omp that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/omp that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ops that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ops that referenced this issue Apr 2, 2024
touhidurabir added a commit to touhidurabir/ops that referenced this issue Apr 2, 2024
@touhidurabir
Copy link
Member

@asmecher all addressed . if all ok, should be good to merge .

asmecher added a commit that referenced this issue Apr 16, 2024
* WIP replace sessions with Laravel

* #9566 Laravel auth system integration

* #9566 fixing session disable const checking and initialization

* #9566 laravel session WIP

* #9566 session regenration and old session manager clean up

* #9566 added remember me functionality

* #9566 fixed logout with auth key details persistence

* #9566 fixed device force logout redirect issue

* #9566 fixed login issue after migration from older session implementation

* #9566 completed sign in/out as and updated session data update in PKPRequest::__destruct

* #9566 updates based on PR review

* #9566 added check to make sure seesion table exists before saving session

* #9566 moved session storage update within register_shutdown_function

* #9566 removed unused function param

* #9566 added upgrade migration

* #9566 fixed issue and doc blocks based on PR review

* #9566 removed older implementation cookie issue override method as fixed by setting domain

* #9566 removed previously added application upgrade settings from migration tool

* #9566 trying to fix mysql build issue

* #9566 added db service provider re-registration at install time

* #9566 added cookie encryption ability

* #9566 session disable check moved to PKPSessionGuard with session user_id key update

* #9566 fixed typo

* #9566 command line session issue

* #9566 clean up of old session manager and dao related implementations

* #9566 session default base path update

* #9566 session default base path revert back

* #9566 fixed cookie path issue

* #9566 removed AUTH_KEY_* const usage and related code

---------

Co-authored-by: Alec Smecher <alec@smecher.bc.ca>
asmecher added a commit to pkp/ojs that referenced this issue Apr 16, 2024
asmecher pushed a commit to pkp/ops that referenced this issue Apr 16, 2024
asmecher added a commit to pkp/orcidProfile that referenced this issue Apr 16, 2024
pkp/pkp-lib#9566 replaced old session manager with new pkp session guard
@asmecher
Copy link
Member Author

Congratulations, @touhidurabir, all merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement:2:Moderate A new feature or improvement that can be implemented in less than 4 weeks.
Projects
None yet
Development

No branches or pull requests

3 participants