Skip to content

[12.0][MIG] password_security - #83

Merged
pedrobaeza merged 21 commits into
OCA:12.0from
shepilov-vladislav:password_security
Apr 12, 2019
Merged

pedrobaeza merged 21 commits into
OCA:12.0from
shepilov-vladislav:password_security

Conversation

@shepilov-vladislav

Copy link
Copy Markdown
Contributor

Continue #66

@pedrobaeza

Copy link
Copy Markdown
Member

@shepilov-vladislav you have to preserve commit history as told before, and Travis is red in this PR. Please amend both things.

@pedrobaeza pedrobaeza added this to the 12.0 milestone Mar 31, 2019
@pedrobaeza

Copy link
Copy Markdown
Member

@shepilov-vladislav

Copy link
Copy Markdown
Contributor Author

@pedrobaeza I have a problem with one test. How I can setup environment like on travis? With my environment all works fine.

@yajo yajo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm reviewing the big diff introduced by this patch and it all seems to come from basically aesthetic styling.

We have a linter to do that job. Please do not "fix" any line that does not fail in a linter (there's a LINT job in travis that you can check).

I commented on 22 of them, but got tired after. Maybe you have a autostyler installed? Please undo all those "fixes" to review again.

Thanks!

Comment thread password_security/__manifest__.py Outdated
Comment thread password_security/__manifest__.py Outdated
Comment thread password_security/controllers/__init__.py Outdated
Comment thread password_security/controllers/main.py Outdated
Comment thread password_security/controllers/main.py Outdated
Comment thread password_security/exceptions.py Outdated
Comment thread password_security/models/__init__.py Outdated
Comment thread password_security/models/__init__.py Outdated
Comment thread password_security/models/res_company.py Outdated
Comment thread password_security/models/res_company.py Outdated
@shepilov-vladislav

shepilov-vladislav commented Apr 3, 2019

Copy link
Copy Markdown
Contributor Author

I'm reviewing the big diff introduced by this patch and it all seems to come from basically aesthetic styling.

We have a linter to do that job. Please do not "fix" any line that does not fail in a linter (there's a LINT job in travis that you can check).

I commented on 22 of them, but got tired after. Maybe you have a autostyler installed? Please undo all those "fixes" to review again.

Thanks!

@yajo I corrected everything you asked for.

@yajo yajo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some minor changes. Mostly code is OK. Thanks!

Comment thread password_security/models/res_config_settings.py Outdated
Comment thread password_security/models/res_config_settings.py Outdated
Comment thread password_security/models/res_config_settings.py Outdated
Comment thread password_security/models/res_config_settings.py Outdated
Comment thread password_security/models/res_config_settings.py Outdated
Comment thread password_security/models/res_users.py Outdated
Comment thread password_security/static/src/js/password_gauge.js Outdated
@pedrobaeza

Copy link
Copy Markdown
Member

Travis is red

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you use new README by fragments system?

Also version should be 12.0.1.0.0.

And finally, please stay with only one migration commit.

@ernestotejeda ernestotejeda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some change requests

Comment thread password_security/models/res_users.py Outdated
Comment thread password_security/models/res_users.py Outdated
@shepilov-vladislav

Copy link
Copy Markdown
Contributor Author

Guys, can you help me. I want to fix my one failed test. But I can not reproduce it. Could you give me instructions on how to raise the same environmental locally for tests(like in travis)? Maybe OCA has docker images for it?

@pedrobaeza

Copy link
Copy Markdown
Member

Do you mean it's not reproducible in local?

@shepilov-vladislav

shepilov-vladislav commented Apr 12, 2019

Copy link
Copy Markdown
Contributor Author

Do you mean it's not reproducible in local?

@pedrobaeza Exactly. How I can reproduce environment like used on travis?

@pedrobaeza

Copy link
Copy Markdown
Member

You can check the log for seeing how Travis is installing first "base" modules, and then installing the rest with --test-enable flag. You can produce the same using that 2 commands.

@shepilov-vladislav

Copy link
Copy Markdown
Contributor Author

You can check the log for seeing how Travis is installing first "base" modules, and then installing the rest with --test-enable flag. You can produce the same using that 2 commands.

I understand what you mean, this was my fallback. I thought that OCA has a special docker image for development needs. And I can use it quickly.

@pedrobaeza

Copy link
Copy Markdown
Member

No, it uses https://github.com/OCA/maintainer-quality-tools/tree/master/travis. When they were done, there weren't support in Travis for Docker.

lasley and others added 12 commits April 13, 2019 00:01
* [ADD] res_users_password_security: New module
* Create new module to lock down user passwords

* [REF] res_users_password_security: PR Review fixes
* Also add beta pass history rule

* [ADD] res_users_password_security: Pass history and min time
* Add pass history memory and threshold
* Add minimum time for pass resets through web reset

* Begin controller tests

* Fix copyright, wrong year for new file

* Add tests for password_security_home
* Left to do web_auth_reset_password

* Fix minimum reset threshold and finish tests

* Bug fixes per review

* [REF] password_security: PR review improvements
* Change tech name to password_security
* Use new except format
* Limit 1 & new api
* Cascade deletion for pass history

* [REF] password_security: Fix travis + style
* Fix travis errors
* self to cls
* Better variable names in tests

* [FIX] password_security: Fix travis errors
* Bump versions
* Installable to True
* Add Usage section to ReadMe w/ Runbot link
* `_crypt_context` now directly exposes the `CryptContext`
* Change all instances of openerp to odoo
* Add current time as password_write_date for admin user in demo, disabling the reset prompt - fixes #652
* Switch security to be on correct model to fix #674
…ord invalid (#859)

* [FIX] password_security: Fix password stored

* [REF] password_security: use a unified check_password private method to validate rules and history password
* Add logic to overloaded web_login action to log out users with expired
passwords, preventing the password reset from being ignored
* Add unit test for new logic
lasley and others added 9 commits April 13, 2019 00:01
This translates to Spanish all missing translations, 31 in total.
Since some implementation details are changed, I had to change some tests that were actually testing the implementation instead of the desired result of the method.
In a normal Odoo deployment, somebody in group *Administration / Access Rights* should be able to create users; but if this addon is installed, it gets this error:

    The requested operation cannot be completed due to security restrictions. Please contact your system administrator.

    (Document type: Res Users Password History, Operation: create)

This is now tested and fixed.
[The `website` addon returns an aditional redirection][1] that makes these tests fail if ran after installing `website`.

The tests were checking the returned value in a funky way anyways.

Now, instead of checking the final returned value, we check directly the parameters sent to the redirection method.

[1]: https://github.com/odoo/odoo/blob/3b85900fafc9469dca6e7c01fca6dac4f55d20f5/addons/website/controllers/main.py#L85-L89
@shepilov-vladislav

shepilov-vladislav commented Apr 12, 2019

Copy link
Copy Markdown
Contributor Author

No, it uses https://github.com/OCA/maintainer-quality-tools/tree/master/travis. When they were done, there weren't support in Travis for Docker.

@pedrobaeza Please put you attention. It is very interesting why the test fail in past.

Explanation:

in test_web_login_expire_pass:

two_days_ago = datetime.now() - timedelta(days=2)
...
user.password_write_date = two_days_ago

in _password_has_expired function:

days = (fields.Datetime.now() - self.password_write_date).days

and after that days == (1 day, 23:59:59.824865).days == 1

I preferred to simply increase the interval to three days in the test. What do you think about that?

Also I added all changes requested by you. So can we merge it now?

@pedrobaeza

Copy link
Copy Markdown
Member

OK, if that avoids that edge cases. I remember at least 2 cases in the past with something similar: a test that failed on leap years, and another that fails at midnight when timezone changes the day...

@pedrobaeza
pedrobaeza merged commit 26cc605 into OCA:12.0 Apr 12, 2019
@OCA-git-bot OCA-git-bot mentioned this pull request Apr 12, 2019
19 tasks
@pedrobaeza

Copy link
Copy Markdown
Member

Thanks for the spent time!

@shepilov-vladislav

Copy link
Copy Markdown
Contributor Author

Thanks for the spent time!

Thank you too for help!

@sbidoul

sbidoul commented May 11, 2019

Copy link
Copy Markdown
Member

@shepilov-vladislav FYI I fixed the README at e147125. They must be simple text fragments, the rest is generated by the bot which assembles the fragments and add boilerplate text.

@moylop260 moylop260 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@shepilov-vladislav

Copy link
Copy Markdown
Contributor Author

@shepilov-vladislav FYI I fixed the README at e147125. They must be simple text fragments, the rest is generated by the bot which assembles the fragments and add boilerplate text.

👍

SiesslPhillip pushed a commit to grueneerde/OCA-server-auth that referenced this pull request Nov 20, 2024
Syncing from upstream OCA/server-auth (11.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.