-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact!: handle scope exceptions with DRF exc handler
- Loading branch information
1 parent
9c1afc2
commit c91d084
Showing
7 changed files
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from rest_framework.views import exception_handler | ||
|
||
from chord_metadata_service.authz.middleware import authz_middleware | ||
from chord_metadata_service.discovery.exceptions import DiscoveryScopeException | ||
|
||
__all__ = ["katsu_exception_handler"] | ||
|
||
|
||
def katsu_exception_handler(exc, context): | ||
# Start with default DRF exception handler | ||
response = exception_handler(exc, context) | ||
|
||
if isinstance(exc, DiscoveryScopeException): | ||
# Allow scope exception responses through the authz middleware (mark them as authorized) | ||
authz_middleware.mark_authz_done(context["request"]) | ||
|
||
return response |