78 Commits

Author SHA1 Message Date
e4f229cc70 Fix T51678: 16bit greyscale PNG images thumbnailing fails
generate_local_thumbnails() now uses pathlib and f-string formatting too,
making the code a lot simpler. Furthermore, I removed unused bits of
resize_and_crop() and simplified the rest.
2018-03-22 17:53:14 +01:00
b10369a867 Removed unused imports 2018-02-13 16:51:42 +01:00
de801e41e3 CLI command for moving all nodes+files to another project
`manage.py operations merge_project src_url dst_url` moves all nodes and
files from the project with `src_url` to the project with `dst_url`.
This also moves soft-deleted files/nodes, as it ignores the _deleted
field. The actual files on the storage backend are copied rather than
moved.

Note that this may invalidate the nodes, as their node type definition
may differ between projects. Since we use direct MongoDB queries the
nodes are moved to the new project anyway. This allows for a
move-first-then-fix approach).
2018-02-13 15:52:21 +01:00
cd42ce6cba Moving blobs between nodes now uses storage API
Instead of only being GCS-specific, it now works for all storage
backends.
2018-02-13 15:36:11 +01:00
08a814525b Implement project undelete as PATCH
This is done via a custom PATCH due to the lack of transactions of MongoDB;
we cannot undelete both project-referenced files and file-referenced
projects in one atomic operation.
2018-01-31 14:15:23 +01:00
f8ff30fb4d (un)delete on project also (un)delete file documents.
Note that undeleting files cannot be done via Eve, as it doesn't support
PATCHing collections. Instead, direct MongoDB modification is used to set
_deleted=False and provide new _etag and _updated values.
2018-01-31 10:08:17 +01:00
4b5a961e14 Speed up authentication by trusting g.current_user if set. 2018-01-31 10:08:17 +01:00
230b2c669c Implement rename-after-Zencoder-is-done using our Storage API.
This means it's no longer GCS-specific, and can be tested using the local
storage implementation.

Required implementation of a rename operation. To mirror Google's API, I've
implemented the renaming of a Blob as a function on the Bucket class.
To me this makes sense, as it requires creating a new Blob instance, which
shouldn't be done by another Blob.
2018-01-26 14:54:34 +01:00
75e2402420 Removed unused import 2018-01-26 12:49:53 +01:00
fb121a9601 Test actual Zencoder notification.
This notification was taken from our API history and was actually sent to
us by Zencoder.
2018-01-26 12:49:45 +01:00
f8c3408f18 Properly handle errors when saving updated file doc after Zencoder notif.
We never checked the return values from the put_internal() call, so errors
would have passed silently into the night.
2018-01-26 12:49:15 +01:00
89ca0516a9 Better handling of Zencoder error notifications. 2018-01-26 12:29:22 +01:00
5ae98507e3 Added missing unittest for encoding.size_descriptor() 2018-01-26 12:15:56 +01:00
66ac8c6587 Modernised ZencoderNotificationTest 2018-01-26 12:15:42 +01:00
fd95135f66 PEP 8 formatting and removal of unused import 2018-01-26 11:42:56 +01:00
987d6d03a6 Fix T49280: Make texture files (in texture node) sortable
Rather than making them sortable, I made them automatically sorted upon
saving the node. The colour map comes first, then the other maps in
alphabetical order.
2018-01-26 11:42:42 +01:00
fd3e795824 Store IP-based org-given roles in the user document.
This is a two-stage approach that happens when a new token is verified
with Blender ID and stored in our local MongoDB:

  - Given the remote IP address of the HTTP request, compute and store the
    org roles in the token document.
  - Recompute the user's roles based on their own roles, regular org roles,
    and the roles stored in non-expired token documents.

This happens once per hour, since that's how long we store tokens in our
database.
2018-01-25 14:01:28 +01:00
270bb21646 Support IP range editing in Organization view_embed 2018-01-25 14:01:28 +01:00
d3f97358d9 Work around Eve not supporting returning binary data 2018-01-25 14:01:28 +01:00
c44f0489bc Backend support for organization IP ranges.
We can now store IP ranges with Organizations. The aim is to have any user
logging in with a remote IP address within such a race will get the
organization roles assigned to the user object stored in the Flask session.

This commit just contains the MongoDB storage and querying, and not yet the
updates to the user.
2018-01-25 14:01:28 +01:00
01f81ce4d5 Send a Blinker signal when someone's subscription status changes
This is very close to the 'roles changed' signal, with the difference that
it is sent only once for multiple role changes.
2017-12-21 12:59:32 +01:00
20ca3f8ee4 Rename blender_id url to blender-id
This fixes a non-compliant to RFC 1178 exception raised by the Django implementation of Blender ID. The issue is debated here https://code.djangoproject.com/ticket/20264.
2017-12-12 18:49:52 +01:00
8a400c5c0f Gracefully handle users with empty full_name 2017-12-08 14:03:30 +01:00
2bcc26860f Removed 'subscriber' cap from 'admin' role
This allows admins to test what happens when users do not have a
subscription. To give the user subscriber capability, just grant demo role
as well.
2017-12-06 12:09:21 +01:00
0b218eb656 Use Blender ID to obtain subscription status.
Instead of performing a call to the Blender Store, call to Blender ID to
get the user's subscription status.

Currently this is performed as a second HTTP call after logging in; in the
future we may want to include the roles in the login response from Blender
ID, so that we can do this in one call instead of two.
2017-11-30 15:28:35 +01:00
390d687f61 Added utility to find project ID from URL.
This is mostly useful for the CLI interface, as the majority of our Pillar
code actually needs more project information than just the ID.
2017-11-03 14:33:19 +01:00
f17453ba10 Added 'operations hash_auth_tokens' CLI command. 2017-10-05 13:04:44 +02:00
c57aefd48b Hash authentication tokens before storing in the database. 2017-10-05 12:57:16 +02:00
230c15d51c Fix snag that happens when PUTting a user document without roles key. 2017-09-14 11:23:35 +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
a6f56a4811 OAuth test: checking email address too 2017-08-25 12:53:21 +02:00
41a82c44c5 Tests for providers callbacks
Also added SERVER_NAME in config_testing and pre-populated the  keys of OAUTH_CREDENTIALS, since the implementation of providers is part of the application.
2017-08-25 10:55:35 +02:00
cecf81a07d Initial tests for OAuthSignIn 2017-08-25 10:55:35 +02:00
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
be12bd7d99 Orgs: allow users to leave an organization 2017-08-24 14:28:18 +02:00
1e1bd83baf Orgs: refresh all members' roles after org changed roles 2017-08-24 14:28:18 +02:00
f1edb901d1 Orgs: allow setting org admin via web interface / PATCH request 2017-08-24 14:28:18 +02:00
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
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
b53d485960 Added access control to organizations Eve endpoints 2017-08-24 14:26:19 +02:00
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
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
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
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
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
bd13d89817 Added permission check to DELETE of nodes. 2017-07-13 17:29:46 +02:00
2ad8c5186c Storage backends: added exists() method
This method returns whether the file exists on the backend.
2017-06-06 15:33:05 +02:00
a7d3ba24b4 Refactor cli scripts in submodules 2017-05-24 19:41:35 +02:00
5e721c61b9 Added function to easily remove someone from a group. 2017-05-24 10:56:53 +02:00
59a95450e5 Updated Eve, Flask, and Werkzeug. Adjusted code to make Pillar work again.
Eve     : 0.6.3   → 0.7.3
Flask   : 0.10.1  → 0.12.2
Werkzeug: 0.11.10 → 0.11.15

Also updated some secondary requirements.
2017-05-18 15:46:02 +02:00