-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to POST /catalogs/:siret/datasets/
- Loading branch information
1 parent
42e8584
commit 2df390f
Showing
10 changed files
with
179 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Callable | ||
|
||
from ..auth.permissions import BasePermission | ||
from ..types import APIRequest | ||
|
||
|
||
class MatchesUserSiret(BasePermission): | ||
def __init__(self, key: Callable[[APIRequest], str]) -> None: | ||
super().__init__() | ||
self._key = key | ||
|
||
def has_permission(self, request: APIRequest) -> bool: | ||
if not request.user.is_authenticated: | ||
raise RuntimeError( | ||
"Running BelongsToOrganization but user is not authenticated. " | ||
"Hint: use IsAuthenticated() & BelongsToOrganization(...)" | ||
) | ||
|
||
user_siret = request.user.account.organization_siret | ||
claimed_siret = self._key(request) | ||
|
||
return user_siret == claimed_siret |
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
Oops, something went wrong.