Skip to content

Commit

Permalink
Fix delete endpoints in Single Table (#383)
Browse files Browse the repository at this point in the history
* Fix delete endpoints in Single Table

* remove creating a list

* fix more things

* Update Dockerfile with json args

---------

Co-authored-by: Maribelle Hannah Gomez <[email protected]>
  • Loading branch information
BinamB and MaribelleHGomez authored Oct 1, 2024
1 parent 62585bf commit 91f8974
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 100 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ RUN COMMIT=`git rev-parse HEAD` && echo "COMMIT=\"${COMMIT}\"" >$appname/index/v
# directory where the app can find Alembic files
WORKDIR /indexd

CMD /dockerrun.sh
CMD ["/dockerrun.sh"]
14 changes: 7 additions & 7 deletions indexd/index/drivers/single_table_alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def update_blank_record(self, did, rev, size, hashes, urls, authz=None):
if authz:
# if an authz is provided, ensure that user can actually
# create/update for that resource (old authz and new authz)
old_authz = [u for u in record.authz] if record.authz else []
old_authz = record.authz if record.authz else []
all_authz = old_authz + authz
try:
auth.authorize("update", all_authz)
Expand Down Expand Up @@ -651,7 +651,7 @@ def append_aliases_for_did(self, aliases, did):

# authorization
try:
resources = [u.resource for u in index_record.authz]
resources = index_record.authz
auth.authorize("update", resources)
except AuthError as err:
self.logger.warning(
Expand Down Expand Up @@ -692,7 +692,7 @@ def replace_aliases_for_did(self, aliases, did):

# authorization
try:
resources = [u.resource for u in index_record.authz]
resources = index_record.authz
auth.authorize("update", resources)
except AuthError as err:
self.logger.warning(
Expand Down Expand Up @@ -732,7 +732,7 @@ def delete_all_aliases_for_did(self, did):

# authorization
try:
resources = [u.resource for u in index_record.authz]
resources = index_record.authz
auth.authorize("delete", resources)
except AuthError as err:
self.logger.warning(
Expand Down Expand Up @@ -762,7 +762,7 @@ def delete_one_alias_for_did(self, alias, did):

# authorization
try:
resources = [u.resource for u in index_record.authz]
resources = index_record.authz
auth.authorize("delete", resources)
except AuthError as err:
self.logger.warning(
Expand Down Expand Up @@ -935,7 +935,7 @@ def delete(self, guid, rev):
if rev != record.rev:
raise RevisionMismatch("revision mismatch")

auth.authorize("delete", [u.resource for u in record.authz])
auth.authorize("delete", record.authz)

session.delete(record)

Expand Down Expand Up @@ -977,7 +977,7 @@ def add_version(
except MultipleResultsFound:
raise MultipleRecordsFound("multiple records found")

auth.authorize("update", [u for u in record.authz] + authz)
auth.authorize("update", record.authz + authz)

baseid = record.baseid
record = Record()
Expand Down
Loading

0 comments on commit 91f8974

Please sign in to comment.