commit fcba03989feed85a3301e53b252f766eabeeba3c
Author: Dan Smith <email address hidden>
Date: Tue Jun 23 07:12:12 2020 -0700
Check authorization before import for image
Right now we only check to see if the user can see the image before
we kick off an import operation. However, that will never work unless
the user is the *owner* of the image (or an admin) which means we
return a 202 to the API caller and then the task fails immediately.
This change makes us check that authorization up front and return an
appropriate error to the user so they know it failed, and avoid
starting a task destined for failure.
Note that there was already a check for a Forbidden result when calling
the import API. However, that used a context.owner=None which could never
happen in reality. A more suitable check would have been to use a context
with a different real owner, but it turns out that the task creation
would have succeeded in that case as well. This test is changed to use
an alternate owner and ensure that we get the forbidden result from the
new check immediately.
Change-Id: I385f222c5e3b46978b40bdefdc28fcb20d9c67d3
Closes-Bug: #1884587
(cherry picked from commit c930638fcf58b43d53903cfc30e06fd6919bdad6)
Reviewed: https:/ /review. opendev. org/738737 /git.openstack. org/cgit/ openstack/ glance/ commit/ ?id=fcba03989fe ed85a3301e53b25 2f766eabeeba3c
Committed: https:/
Submitter: Zuul
Branch: stable/ussuri
commit fcba03989feed85 a3301e53b252f76 6eabeeba3c
Author: Dan Smith <email address hidden>
Date: Tue Jun 23 07:12:12 2020 -0700
Check authorization before import for image
Right now we only check to see if the user can see the image before
we kick off an import operation. However, that will never work unless
the user is the *owner* of the image (or an admin) which means we
return a 202 to the API caller and then the task fails immediately.
This change makes us check that authorization up front and return an
appropriate error to the user so they know it failed, and avoid
starting a task destined for failure.
Note that there was already a check for a Forbidden result when calling
the import API. However, that used a context.owner=None which could never
happen in reality. A more suitable check would have been to use a context
with a different real owner, but it turns out that the task creation
would have succeeded in that case as well. This test is changed to use
an alternate owner and ensure that we get the forbidden result from the
new check immediately.
Change-Id: I385f222c5e3b46 978b40bdefdc28f cb20d9c67d3 d53903cfc30e06f d6919bdad6)
Closes-Bug: #1884587
(cherry picked from commit c930638fcf58b43