Daily updates from Odoo
Monday, March 19, 2018
1 change
Security fixes and vulnerability patches
Odoo now supports secure access tokens and API keys for user authentication, allowing third-party apps to connect without sharing a user's password. Passwords, OAuth tokens, and API keys are stored as encrypted tokens, improving credential security while also adding better tracking and expiry handling for token use.
Original PR description
[ADD] base: token authentication ``` Allow users authentication by access tokens: - a user is allowed to authenticate if he uses as login key a token (`res.users.token`) associated to his account…
[ADD] base: token authentication ``` Allow users authentication by access tokens: - a user is allowed to authenticate if he uses as login key a token (`res.users.token`) associated to his account (`user_id`) which is not expired (`expiry_date` is greater than now), - `password` is removed from the `res.users` model and is replaced by a `res.users.token` record of type `password`, - API keys can be created to allow third-party apps to authenticate as specific users without the need of their password. An expiration date can be set on the token, - All tokens are stored encrypted, and the hashes are never reachable through the ORM classic methods (`read` / `browse`). The table column containing the hashes is created and filled using pure SQL. In other words, it is not set as a classic ORM field. The `auth_crypt` module is therefore no longer needed, and therefore removed, as all users password are now encrypted by default. Besides, the API keys are never stored in database, not even in a transient model. ``` --- [ADD] auth_oauth: adaptation to the token authentication ``` Following the introduction of the `res.users.token` model, `auth_oauth` now stores the OAuth access tokens among the `res.users.token`, encrypted. ``` --- [IMP] res_users: `check_credentials` performances ``` When a lot of tokens are available for a user, checking one by one all possible tokens take some times, while `check_credentials` is a very response time sensitive method. With this revision, tokens are being checked type by type (the token type `password` being first, and only one token of type `password` per user), and use the token prefix (if set) to exclude tokens for which the prefix is not even correct, making the set of tokens to check way smaller. ``` --- [ADD] res_users: `uid_cache` invalidation ``` `uid_cache` is a dict which is used as a cache containing the users valid passwords, to avoid calling `check_credentials`, which can be costly, too often. This revision allows: - to add values associated to the user cached password, - to invalid a cached password according to these values. At the moment, it add the expiry date of the token to the cache, along the token, to reject the token when the expiration date is over. The OAuth authentication could use these new methods in order to invalid the cached access tokens if they haven't been checked enough recently to the OAuth authority server. ``` --- [FIX] res_users: move the `__uid_cache` to the pool ``` The `__uid_cache` (the dict used as cache for the user passwords) was formerly defined on the python Class Users Which is shared between all databases, and therefore was potentially accessible from one database to another. (It was not thanks to the double `_`, but the resource was) Besides, this revision allow the invalidation of this cache for all workers, not just the one triggering the cache invalidation. ``` --- [ADD] base: token used to connect in `res.users.log` ``` The token used by the user to sign in is mentioned in the `res.users.log`, in order to: - Know which token (password, oauth, api key) was used recently to sign in - identify tokens that have not been used since a long time, for cleaning purposes. ```