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

[16.0][MIG] auth_session_timeout #507

Merged
merged 29 commits into from
Sep 23, 2023

Conversation

bosd
Copy link
Contributor

@bosd bosd commented Apr 20, 2023

Standard migration using odoo-module-migrator /ocabot migration auth_session_timeout .

@bosd bosd force-pushed the 16.0-mig-auth_session_timeout branch 2 times, most recently from 5cf96e3 to 20f76af Compare April 20, 2023 15:40
@bosd
Copy link
Contributor Author

bosd commented Apr 20, 2023

/ocabot migration auth_session_timeout

@OCA-git-bot
Copy link
Contributor

Sorry @bosd you are not allowed to mark the addon tobe migrated.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

@Kaliuta
Copy link

Kaliuta commented Apr 24, 2023

v 16.0
A message appears after a set time:
"Your Odoo session expired. The current page is about to be refreshed. "

When I click "OK", the page reloads, but I remain logged in.

@bosd
Copy link
Contributor Author

bosd commented May 3, 2023

A message appears after a set time: "Your Odoo session expired. The current page is about to be refreshed. "

When I click "OK", the page reloads, but I remain logged in.

I can replicate this behaviour..
Any ideas why it is not working?


# If session terminated, all done
if terminated:
raise SessionExpiredException("Session expired")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bosd ,

I can replicate this behaviour..
Any ideas why it is not working?

I see this line making the issue
Because you raise an exception here, then everything is reverted, the user can not log out

For solution, we should return here, not raise

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bosd please help to check, thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For solution, we should return here, not raise

I'm having some personal time. Later, in a couple of weeks I will get back to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For solution, we should return here, not raise

@Leonidas-VII Thanks for the suggestion, I made the commit. It does not seem to resolve the problem.

I have the impression it is related to these lines:

https://github.com/OCA/server-auth/pull/507/files#diff-1648a6bceb7d2da7ef9fc6326f0f894ee39f11f613d80c83ae53849fdb5698eaR51-R52

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For return, we can just return anything here, nothing is done with the result. So we don't need to return the exception.

Meanwhile, the issue of a refresh not leading to an expiration I think is caused by this - can you cherry-pick it in?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a question: why don't we add the auto-reload function after 5/10 seconds instead of clicking on the button "OK"?

pedrobaeza and others added 22 commits June 6, 2023 12:39
… True * Add Usage section to ReadMe w/ Runbot link * `_crypt_context` now directly exposes the `CryptContext` * Change all instances of openerp to odoo * Add test coverage to IrConfigParameter * Add test coverage for res.users * Remove db from `get_session_parameters` method call * Remove deprecated skiparg for ormcache * Fix tests & lint * Switch cache to use self.cr.dbname * Fix ormcache
* Module auth_session_timeout:
---------------------------

* Refactor to allow other modules to inherit and augment or override the following:
** Session expiry time (deadline) calculation
** Ignored URLs
** Final session expiry (with possibility to late-abort)
* Re-ordered functionality to remove unnecessary work, as this code is called very often.
* Do not expire a session if delay gets set to zero (or unset / false)

* WIP

* Fixed flake8 lint errors

* Fixed flake8 lint errors

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Module: auth-session-timeout: Refactor ResUser tests to use `unittest.mock` patching

* Module: auth_session_timeout: Fixed flake8 lint errors

* Module: auth_session_timeout: Fixed flake8 lint errors
…e backwards compatibility methods that were retained during v9 rework * Upgrade API and rename a few things for PEP-8 * Switch to HttpCase for tests * Switch to isolated build
… (#1070)

* corrects AttributeError: 'HttpRequest' object has no attribute 'http'

* updates the module version number for pull request #1070
New changes for move module, clean module, apply new oca guideline and make
compatible with 11.0:

* Move module from oca/server-tools:10.0  to oca/server-auth:11.0
* Remove .DS_Store files, addd by mistake in early changes and not needed.
* Fix error when make RPC request. Applied thanks to comment added by @christophlsa. For more information go to OCA/server-tools#1163 (review)
* Update version to the first one in 11.0
* Update README to match new guideline
* Remove she bang coding
* Use _authenticate method instead of deprecated method check. For more information go to https://github.com/odoo/odoo/blob/11.0/odoo/http.py#L1049
* Improve auth_session_timeout method return raise SessionExpiredException exception instead of False. This will show a "session expired please reload page" message to the user.
* Fix update unitet test. make then turn green and the update then to make them match with new changes

  - There was not getmtime() result definied in this test case, For that reason was returning a MagicMock() object, For this case their are trying to test that the session is valid, this is the same that the path of the file with session is not expired. To simulate that I just updated for the test case the getmtime() result to a value that will be greater than the delay expected: I used the current time This way when evaluationg if the sessions is expire will return False instead of TypeError: unorderable types: MagicMock() < float() The unit test still works the same and the result is without errors.

* Fix plylint errors:

  - E302 expected 2 blank lines,
  - Not used variable and not valid var name. Remove e varaible since is not valid name and this one is not been used.
Currently translated at 100.0% (3 of 3 strings)

Translation: server-auth-12.0/server-auth-12.0-auth_session_timeout
Translate-URL: https://translation.odoo-community.org/projects/server-auth-12-0/server-auth-12-0-auth_session_timeout/pt_BR/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-auth-13.0/server-auth-13.0-auth_session_timeout
Translate-URL: https://translation.odoo-community.org/projects/server-auth-13-0/server-auth-13-0-auth_session_timeout/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-auth-13.0/server-auth-13.0-auth_session_timeout
Translate-URL: https://translation.odoo-community.org/projects/server-auth-13-0/server-auth-13-0-auth_session_timeout/
Make it so session timeout doe not apply to requests
to a route with auth_method="public".

Forward port of OCA#258
Currently translated at 100.0% (3 of 3 strings)

Translation: server-auth-14.0/server-auth-14.0-auth_session_timeout
Translate-URL: https://translation.odoo-community.org/projects/server-auth-14-0/server-auth-14-0-auth_session_timeout/pt_BR/
@thomaspaulb
Copy link
Contributor

/ocabot migration auth_session_timeout

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Jul 2, 2023
@OCA-git-bot
Copy link
Contributor

The migration issue (#426) has not been updated to reference the current pull request because a previous pull request (#524) is not closed.
Perhaps you should check that there is no duplicate work.
CC @dsolanki-initos

@zuher83
Copy link

zuher83 commented Jul 18, 2023

I think everything is ready now

@bosd
Copy link
Contributor Author

bosd commented Jul 19, 2023

I think everything is ready now

I still did not include the cherry pick. Will do it later this week.

@thomaspaulb
Copy link
Contributor

When you do so, could you also check if this should be applied for 16.0 too?

gfcapalbo and others added 2 commits August 12, 2023 23:15
…, but /web is a public route, so it does not trigger the session check but it does trigger session save, so the file mtime is updated before the second HTTP call makes the check takes place, and session is not expired
@bosd
Copy link
Contributor Author

bosd commented Aug 12, 2023

Excuse me for the delay. Cherry picks are now included.

@thomaspaulb
Copy link
Contributor

Code approved, but it's probably good if someone still tests this on runbot once more to be sure. @KKamaa maybe you can do a sanity check here since you've been busy with the module

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@thomaspaulb
Copy link
Contributor

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-507-by-thomaspaulb-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 2263cda into OCA:16.0 Sep 23, 2023
6 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 26d6505. Thanks a lot for contributing to OCA. ❤️

@bosd
Copy link
Contributor Author

bosd commented Sep 23, 2023

@CasVissers-360ERP It's Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.