Skip to content

Commit

Permalink
feat: Add JwtAuthentication as a default DRF auth class.
Browse files Browse the repository at this point in the history
By default DRF sets 'DEFAULT_AUTHENTICATION_CLASSES' to:

```
[
    'rest_framework.authentication.SessionAuthentication',
    'rest_framework.authentication.BasicAuthentication'
]
```

We also want to allow for JWT Authentication as a valid default auth
choice.  This will allow users to send JWT tokens in the authorization
header to any existing API endpoints and access them. If any APIs have
set custom authentication classes, this will not override that.

I believe this is a fairly safe change to make since it only adds one
authentication class and does not impact authorization of any of the
endpoints that might be affected.

Note: This change changes the default for both the LMS and CMS because
`cms/envs/common.py` imports this value from the LMS.
  • Loading branch information
feanil committed Jul 26, 2023
1 parent 8098169 commit f2a61dc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3294,6 +3294,11 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
'DEFAULT_AUTHENTICATION_CLASSES': [
'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication'
],
'EXCEPTION_HANDLER': 'openedx.core.lib.request_utils.expected_error_exception_handler',
'PAGE_SIZE': 10,
'URL_FORMAT_OVERRIDE': None,
Expand Down

0 comments on commit f2a61dc

Please sign in to comment.