-
-
Notifications
You must be signed in to change notification settings - Fork 860
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create auth scheme for private URL keys
This commit creates a new authentication class that takes an "Authorization" header with a private URL key (prefixed by "Key"), to identify participants with their use of API endpoints where appropriate. It will be necessary for participants to use the API with private keys when the new frontend will be in use. Extra permissions logic has been added to ensure participants only have access to their data, to act as themselves, and only if the relevant preference has been set. A couple endpoints have been adapted: * Ballots: One's own ballots can always be seen, but preference on whether to create them. Teams can see theirs on the "private_ballots_released" setting. * Feedback: Participants can always see the feedback they have submitted but not whether it is ignored. If "participant_ballots" set, either no auth or private URL key is needed. * Check-in: Participants can check themselves in and out if self-check- in active. Added a fake doc comment to avoid the LogActionMixin text from appearing on all endpoint docs.
- Loading branch information
Showing
6 changed files
with
173 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
def is_staff(context): | ||
# OpenAPI generation does not have a view (sometimes context is also None in that circumstance). | ||
# Avoid redacting fields. | ||
return context is None or 'view' not in context or not context['request'].user.is_anonymous | ||
return context is None or 'view' not in context or not getattr(context['request'].user, 'is_anonymous', True) |
Oops, something went wrong.