-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Authentication classes added to tagging API views (#98)
* Authentication classes added to tagging API views * Cast taxonomies before serialize in TaxonomySerializer * Test updated
- Loading branch information
Showing
4 changed files
with
73 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
Utilities for the API | ||
""" | ||
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication # type: ignore[import] | ||
from edx_rest_framework_extensions.auth.session.authentication import ( # type: ignore[import] | ||
SessionAuthenticationAllowInactiveUser, | ||
) | ||
|
||
|
||
def view_auth_classes(func_or_class): | ||
""" | ||
Function and class decorator that abstracts the authentication classes for api views. | ||
""" | ||
def _decorator(func_or_class): | ||
""" | ||
Requires either OAuth2 or Session-based authentication; | ||
are the same authentication classes used on edx-platform | ||
""" | ||
func_or_class.authentication_classes = ( | ||
JwtAuthentication, | ||
SessionAuthenticationAllowInactiveUser, | ||
) | ||
return func_or_class | ||
return _decorator(func_or_class) |
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