Commit Graph

190 Commits

Author SHA1 Message Date
Sybren A. Stüvel 9cce441f6c Removed unused code 2017-09-19 13:38:30 +02:00
Pablo Vazquez b98771f067 Improvements to image thumbnailing
- Optimize JPEGs and increase quality from 75 to 95
- Don't always convert to RGB, first check if RGBA and save as PNG optimized

Thanks to Dr. Sybren and Francesco for review and feedback
2017-09-17 21:49:55 +02:00
Dalai Felinto 7d48c02fa3 Expand user schema to support extension_props 2017-09-17 00:25:09 +02:00
Sybren A. Stüvel 970376ed56 Removed debug print 2017-09-15 17:04:23 +02:00
Sybren A. Stüvel 62954ac157 Latest assets/comments: using Mongo aggregation instead of Python code 2017-09-15 16:47:40 +02:00
Sybren A. Stüvel dc50d6e941 Add more logging to find cause of KeyError
There can be a KeyError accessing permission['methods'], but our current
logging doesn't provide enough information as to determine when this
happens. Rather than bluntly fixing the issue, I added logging to try and
find out how we get a 'methods'-less permission dict in the first place.
2017-09-15 11:02:31 +02:00
Sybren A. Stüvel eba28b4eb4 File link refresh: report on every N refreshed links
This makes it easier to see what the Celery worker is actually working on
when refreshing a large number of links.

It'll report on every N refreshed links, where N = link_count/25 but
clamped to N ∈ [5, 100]
2017-09-14 15:10:09 +02:00
Sybren A. Stüvel 44f473221f File link refresh: ignore soft-deleted files 2017-09-14 15:06:37 +02:00
Sybren A. Stüvel 230c15d51c Fix snag that happens when PUTting a user document without roles key. 2017-09-14 11:23:35 +02:00
Sybren A. Stüvel 16bf193b0e Added soft-delete to the files schema.
This allows us to soft-delete orphan files, at least until we know
that the orphan file detection is solid and can really be trusted.
2017-09-13 14:05:28 +02:00
Sybren A. Stüvel a8511c9db5 Gracefully handle read timeouts when communicating with BlenderID 2017-09-12 16:30:11 +02:00
Francesco Siddi 901fea3361 Do not assume that users and groups keys exist in permissions 2017-09-11 22:35:44 +02:00
Sybren A. Stüvel 4e5ce71a52 File storage link refreshing: log nr of documents to refresh. 2017-09-07 15:53:16 +02:00
Dalai Felinto 216b9278af A user should not be able to vote on own content
This should be hidden in the UI as well, but the backend should support this too.
We also want to set initial rating of 1 for contents that need it.

This commit includes a new unittest for this case.

Reviewers: sybren

Differential Revision: https://developer.blender.org/D2825
2017-09-06 13:51:32 +02:00
Sybren A. Stüvel eb467474f8 Make our require_login() optionally redirect to the login page
This mimicks the behaviour of flask_login. In our case, it only redirects
when redirect_to_login=True and the user is anonymous. Otheriwse it still
results in a 403 Forbidden response.
2017-09-06 12:07:20 +02:00
Sybren A. Stüvel 3a3b3c3269 Revert "Replaced config SCHEME with Flask's own PREFERRED_URL_SCHEME setting."
This reverts commit 8318d4b1f6.
2017-09-01 16:19:58 +02:00
Sybren A. Stüvel 314f0b8dbe Quote token when logging
This helps when debugging strange tokens.
2017-09-01 11:21:02 +02:00
Sybren A. Stüvel 8318d4b1f6 Replaced config SCHEME with Flask's own PREFERRED_URL_SCHEME setting.
This prevents us from explicitly passing SCHEME to url_for() calls.

NOTE: this possibly requires an update to your config_local.py
2017-08-31 14:37:35 +02:00
Sybren A. Stüvel 62542f0329 Rolled back some flask_login and g.current_user integration
Setting flask_login.current_user ourselves was a bad idea, and messed up
flask_login's internal administration. Our code now just manages
g.current_user in these specific instances, which works fine.
2017-08-30 12:39:46 +02:00
Sybren A. Stüvel bdd603fb17 Using new UserClass instances everywhere:
- No more direct access to g.current_user, unless unavoidable.
  - Using pillar.auth.current_user instead of g.current_user or
    flask_login.current_user.
  - p.a.current_user is never checked against None.
  - p.a.current_user.is_authenticated or is_anonymous is used, and never
    together with a negation (instead of 'not is_anon' use 'is_auth').
  - No more accessing current_user a a dict.
  - No more checks for admin role, use capability check instead.
2017-08-29 11:34:48 +02:00
Francesco Siddi 6b3e523036 Remove Flask-OAuthlib and oauth_blender_id from Pillar
We switch completely to a rauth-based approach, allowing multiple providers for authentication.
2017-08-25 10:53:22 +02:00
Francesco Siddi 6e9a539d61 Fix typo 2017-08-25 10:52:52 +02:00
Francesco Siddi 23b856b073 Move Blender ID to extensible OAuth
Also, added support for Google OAuth.
2017-08-25 10:51:45 +02:00
Francesco Siddi c827dc4ed2 Initial work to support multiple OAuth clients 2017-08-25 10:51:45 +02:00
Sybren A. Stüvel b9ae4396e5 Orgs: show "My Organizations" in the user's menu
This is shown only when the user is member of or administrator for one or
more organizations, otherwise it's hidden.
2017-08-24 14:28:18 +02:00
Sybren A. Stüvel be12bd7d99 Orgs: allow users to leave an organization 2017-08-24 14:28:18 +02:00
Sybren A. Stüvel 598b59c0c6 Orgs: gracefully handle 'not enough seats' error 2017-08-24 14:28:18 +02:00
Sybren A. Stüvel 1e1bd83baf Orgs: refresh all members' roles after org changed roles 2017-08-24 14:28:18 +02:00
Sybren A. Stüvel f1edb901d1 Orgs: allow setting org admin via web interface / PATCH request 2017-08-24 14:28:18 +02:00
Sybren A. Stüvel 08294e2f14 Orgs: allow admins to set seat count and org_roles 2017-08-24 14:28:18 +02:00
Sybren A. Stüvel 4116357447 Orgs: some small fixes, mostly for stability / corner cases 2017-08-24 14:28:18 +02:00
Sybren A. Stüvel e9cb235640 Added web interface for organizations.
It looks like crap, but it allows you to edit the details and the members.
2017-08-24 14:28:18 +02:00
Sybren A. Stüvel 64eab850c5 Orgs: pillar admins can always edit an organization 2017-08-24 14:28:17 +02:00
Sybren A. Stüvel c6eebc4eae Orgs: allow setting location field by PATCH 2017-08-24 14:28:17 +02:00
Sybren A. Stüvel 1bd6e07fe2 Orgs: Allow adding individual known users by user ID.
This is used for the selection by user search.
2017-08-24 14:28:17 +02:00
Sybren A. Stüvel 1ad13d048f Some extra type safety checks 2017-08-24 14:28:17 +02:00
Sybren A. Stüvel cfde720b1d Orgs: PATCH op to batch-add emails as members now strip()s emails
It also refuses to add empty emails.
2017-08-24 14:28:11 +02:00
Sybren A. Stüvel 5d17d892a4 Orgs: Use current_user() in PATCH handler 2017-08-24 14:28:02 +02:00
Sybren A. Stüvel 40172bf8b5 Orgs: Use create-organization capability to control access
This is more explicit and future-proof than checking for admin cap.
2017-08-24 14:27:52 +02:00
Sybren A. Stüvel 72404d0fd9 Handle registration of previously unknown organization members.
When a new user is created, two things happen:
  - before inserting into MongoDB, the organizational roles are given
  - after inserting, the organizations are updated to move the user from
    `unknown_members` to `members`.
2017-08-24 14:26:19 +02:00
Sybren A. Stüvel b53d485960 Added access control to organizations Eve endpoints 2017-08-24 14:26:19 +02:00
Sybren A. Stüvel cf51d1a280 Added utility function current_user() that acts like flask_login.current_user
This actually returns an AnonymousUser object, instead of None, when the
user is not logged in.

For compatibility with existing code, this function doesn't set
g.current_user to that AnonymousUser instance. We may decide to do this
later.
2017-08-24 14:26:19 +02:00
Sybren A. Stüvel efc1890871 Added PATCH support for organizations
With a PATCH request you can now:
  - assign users,
  - remove a user,
  - edit the name, description, and website fields.

Only the organization admin user can do this.
2017-08-24 14:26:19 +02:00
Sybren A. Stüvel 93d534fe94 Added Organization Manager.
This is a Flamenco/Attract-style Manager object that's instantiated by
the PillarApplication. It can create Organizations and assign/remove
users.

Also I updated the Organization schema to reflect the currently desired
design.

NOTA BENE: this does not include any security/authorisation checks on Eve's
organizations collection.
2017-08-24 14:25:52 +02:00
Sybren A. Stüvel 87afbc52f6 Updated do_badger to take an optional set of roles.
The 'role' parameter now must be passed as keyword arg instead of
positional arg. Either 'role' or 'roles' must be given.
2017-08-23 08:59:23 +02:00
Francesco Siddi 15de24214a Decouple upload_and_process from stream_to_storage
The stream_to_storage function is still quite large, and this is a first step at refactoring it. stream_to_storage can be used for files that are uploaded on the server without the /stream endpoint (for example downloaded from a link).
2017-08-22 13:26:12 +02:00
Sybren A. Stüvel 2b09711eb0 Load user capabilities from Pillar config and allow extensions to extend.
Default caps can be overridden using the USER_CAPABILITIES name in
config_local.py. These can be extended by Pillar Extensions.
2017-08-22 11:31:17 +02:00
Sybren A. Stüvel 566f2a4835 Late-initialise CLI user & late-import UserClass class
This may fix some unit tests issues.
2017-08-22 09:41:38 +02:00
Sybren A. Stüvel 575a7ed1a7 Introduced role-based capability system.
It's still rather limited and hard-coded, but it works.
2017-08-18 14:47:42 +02:00
Sybren A. Stüvel 566a23d3b6 Unified user representation for web and API calls
Both approaches now use a pillar.auth.UserClass instance. g.current_user
is now always set to that instance, even for web entry points.

This UserClass instance can still be keyed like the old dict, but this is
for temporary compatibility and shouldn't be relied on in new or touched
code.
2017-08-18 13:19:34 +02:00