Commit Graph

152 Commits

Author SHA1 Message Date
Robert Raposa
3f147335ca docs: enhance mobile JWT ADR (#30906)
As part of the implementation of this ADR, we determined that we needed
to make some of the endpoints that return JWTs able to produce
asymmetric JWTs as needed, since asymmetric JWTs are a requirement
in certain cases. This ADR update notes this additional consequence.
2022-09-19 12:23:59 -04:00
Sarina Canelake
cf5fa64bd7 fix: update repo paths that stayed in the edx org
Co-authored-by: Kyle McCormick <kdmc@pm.me>
2022-09-15 14:52:28 -04:00
Sarina Canelake
4a2f231302 fix: fix github url strings (org edx -> openedx) 2022-09-15 14:52:28 -04:00
jawad khan
dc256139f3 feat: Exchange jwt token with session cookies (#29963)
Exchange jwt token with session cookies so that it can work on mobile.
Mobile platform is migrating to jwt and for accessing  xblocks we need session cookies in exchnage of jwt token.
For additional details, see
https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/oauth_dispatch/docs/decisions/0013-mobile-migration-to-jwt.rst

LEARNER-8518
2022-08-31 13:29:52 +05:00
Robert Raposa
49dcb68a5e docs: fix restricted app adr status (#30677)
The decision to provide Restricted Applications expired
JWTs was superseded by another ADR. This commit simply
adds clarity around that change.

Co-authored-by: Phillip Shiu <pshiu@users.noreply.github.com>
2022-07-20 17:02:33 -04:00
jawad khan
2dc7990653 feat: Added token grant_type in JWT payload (#30519)
To exchange jwt with session cookies we need to determine JWT grant type in
AccessTokenExchangeView. JWT only having password grant type will be allowed to exchange session.
Added ADR for mobile migration to JWT authentication.

LEARNER-8886
2022-06-30 16:49:11 +05:00
jawad khan
fe6b666f5b feat: exchange third party auth token with jwt token (#30283)
Exchange third party auth token wiith jwt token
since mobile platform is moving to jwt token we
need jwt token instead of access token now.

LEARNER-8517

Co-authored-by: Robert Raposa <rraposa@edx.org>
2022-06-21 14:58:39 -04:00
Robert Raposa
432cde31a5 refactor: add create_jwt_token_dict (#30485)
Moves the functionality from views._get_jwt_dict_from_access_token_dict
to a new method jwt.create_jwt_token_dict, which create a JWT version
of the passed token_dict. Also updates create_jwt_from_token to wrap
this call and return the "access_token" from the dict.

This will hopefully make it less likely that the token
dict attributes could get out of sync with the claims
inside the JWT.
2022-05-25 17:02:19 -04:00
Robert Raposa
d321ed5ccd refactor: extract shareable jwt methods (#30451)
Extract some jwt related methods to enable reuse across views.
This is in preparation for a change to AccessTokenExchangeView.

Co-authored-by: jawad-khan <jawadkhan444@gmail.com>
2022-05-25 08:53:36 -04:00
Robert Raposa
98d990d7af fix: remove reference to ApplicationOrganization (#30446)
References to ApplicationOrganization were removed two
years ago in the following PR:
https://github.com/openedx/edx-platform/pull/23199

However, it looks like one reference was missed.

ARCHBOM-992
2022-05-20 13:42:12 -04:00
Robert Raposa
3fc852f53c feat!: change JWT access token expires (#30432)
Introduces JWT_ACCESS_TOKEN_EXPIRE_SECONDS setting. This is the number
of seconds a JWT access token remains valid. We use this custom
setting for JWT formatted access tokens, rather than the
django-oauth-toolkit setting ACCESS_TOKEN_EXPIRE_SECONDS, because the
JWT is non-revocable and we want it to be shorter lived than the
legacy Bearer (opaque) access tokens, and thus to have a smaller
default.

BREAKING CHANGE: The thing that is breaking is that JWT access tokens
will now have a 1 hour default, instead of a 10 hours default. If
third-party scripts are appropriately checking/refreshing the access
token, this should be ok. However, you can always override with a
longer duration temporarily. From a security perspective, we don't
recommend a longer duration, and you may consider a shorter duration.

ARCHBOM-2099
2022-05-19 09:46:17 -04:00
Awais Qureshi
bc45f1ee48 fix: Removed usage of djangoratelimitbackend. (#30116)
* fix: Removed usage of djangoratelimitbackend.
2022-03-25 15:27:39 +05:00
Usama Sadiq
1cebd3ed7b Remove django-ratelimit-backend (#30054)
* fix: remove the usage of django-ratelimit-backend

Co-authored-by: Awais Qureshi <awais.qureshi@arbisoft.com>
2022-03-24 17:21:56 +05:00
Mohammad Ahtasham ul Hassan
a838ab4b01 fix: fixed django4 warnings (#29643) 2022-03-04 15:03:02 +05:00
Awais Qureshi
5b8cc00964 test: Fixed test failures due to randomization. (#29822)
* test: Fixed test failures due to randomization.
2022-01-26 19:48:55 +05:00
Robert Raposa
b82144bb83 feat!: remove misleading JWT monitoring (#29142)
BREAKING CHANGE: Removed unused and misleading custom attributes
  used for monitoring:
* `jwt_expires_in`: Removed because it is constant for all requests
  and just repeating the setting value. It was also misleading.
* `jwt_is_asymmetric`: Removed because multiple JWTs might be created,
  and only the last would be reported, which is misleading. This was
  meant to help with a future project to get everyone on to asymmetric
  JWTs, but can be added when needed, and probably should ONLY monitor
  deprecated (symmetric) usage that needs to be fixed. That can be left
  for another day.
2021-10-28 10:06:13 -04:00
M. Zulqarnain
834dabb399 feat: New codemods on OpenedX 2 (#28777) 2021-10-28 16:45:53 +05:00
M. Zulqarnain
9833134fae Post Django 3.2 Cleanup (#29069)
* chore: Post Django 3.2 Cleanup
2021-10-22 13:55:16 +05:00
Soban Javed
56d12bf230 feat!: upgrade pyjwt to version 2.1.0 2021-09-17 16:08:15 +05:00
Maria Grimaldi
2ee52ea96c refactor: replace some create_user with UserFactory to avoid non-existent profile errors 2021-08-24 15:49:21 -04:00
Awais Qureshi
56466ba329 chore: Django3 has removed python_2_unicode_compatible.
Execute the codemodes.
2021-07-28 20:38:19 +05:00
Manjinder Singh
1a026c5e15 refactor: noop migration for testing (#28150)
This is a noop migration for testing changes
to the deployment pipeline.

This is a copy of: #28078
2021-07-12 11:44:38 -04:00
Manjinder Singh
9b25e2d3da refactor: noop migration for testing (#28078)
This is a noop migration for testing changes
to the deployment pipeline.
2021-07-01 14:28:00 -04:00
Robert Raposa
fdd057b2ad refactor: noop migration for testing (#28052)
This is a noop migration for testing changes
to the deployment pipeline.
2021-06-30 14:49:10 -04:00
Usama Sadiq
46993bff00 refactor: pyupgrade second iteration (#27461) 2021-05-11 11:24:07 +05:00
Jawayria
8fc7333982 Refactor: Remove unused imports
Removed unused imports from openedx/core/djangoapps/{dark_lang, django_comment_common, embargo, lang_pref, oauth_dispatch, plugins, programs, schedules}
2021-04-06 17:11:59 +05:00
M. Zulqarnain
dfe6f21e4a refactor: pyupgrade in monkey_patch, oauth_dispatch, olx_rest_api (#26917) 2021-03-16 14:37:08 +05:00
M. Zulqarnain
6e7af5eab6 lint amnesty in monkey_patch,oauth_dispatch,olx_rest_api and password_policy (#26376) 2021-02-04 17:10:16 +05:00
Aarif
f99229fa6f replaced unittest assertions pytest assertions (#26242) 2021-02-04 10:06:28 +05:00
Kyle McCormick
151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00
Tim McCormack
705ad07524 A few other "metric" names in files touched in previous renaming PRs 2020-09-25 19:11:30 +00:00
Tim McCormack
ba9ee4e151 ARCHBOM-1494: Refer to custom attributes, not metrics, especially with edx-django-utils (#25010)
This uses the new names introduced in edx-django-utils
3.8.0 (edx/edx-django-utils#59), which we're already using, as
well as updating a few other locations where we incorrectly refer
to New Relic custom metrics instead of custom attributes.

Includes a couple of unrelated lint fixes in a file I modified.
2020-09-18 13:33:50 +00:00
Robert Raposa
e89e1a4038 update oauth_dispatch ADRs to accepted (#24474)
The following oauth_dispatch ADRs are being
marked as accepted, because they were implemented
and are in use in Open edX.
- 0006-enforce-scopes-in-LMS-APIs.rst
- 0007-include-organizations-in-tokens.rst

Given that, scopes have still not been widely
adopted in Open edX, which would require additional
decisions and investment.
2020-07-14 09:57:30 -04:00
Aarif
27480cdd2f Removed deprecated future imports 2020-06-23 18:51:43 +05:00
Jeremy Bowman
3309078242 Prepare for django-oauth-toolkit 1.3.2 upgrade (#23637)
Prepare to upgrade to django-oauth-toolkit (module name oauth2_provider) 1.3.2 concurrently with the Django 2.2 upgrade (versions after 1.1.3 dropped support for Django 1.11). Key points:

* We can stop using a commit hash since versions 1.3.0 through 1.3.2 have been released since that commit.
* The validator in oauth_dispatch migration 0002 has been removed from DOT, but the whole table was removed in migration 0004 anyway. Newer DOT versions moved where redirect URI validation happens so it's no longer needed here.
* DOT 1.3.0 squashed its original 6 migrations and immediately deleted them. This required some changes in oauth_dispatch migrations 0006 and 0007 to deal with either numbering system.

When deploying to stage and production, we'll need to delete the history for oauth2_provider migrations 0002-0006 first (the new squashed 0001 migration has the same name as the original 0001). The deployment with DOT 1.3.2 will add a new 0002 migration which should then apply cleanly on the existing database state.

Should resolve https://openedx.atlassian.net/browse/BOM-1456 .
2020-04-06 19:10:19 -04:00
Awais Qureshi
e66de4e49e BOM-1489
None is not a valid value for posting.
2020-04-04 19:52:18 +05:00
Awais Qureshi
0f002bafb8 BOM-1399
checking django-wiki and fixing deprecation warnings.
2020-03-16 14:37:18 +05:00
usamasadiq
84744fdf88 BOM-1277 Removed constraint on requests-oauthlib and updated oauthlib 2020-03-11 11:15:24 +05:00
Robert Raposa
d28889db1a delete oauth2.enforce_jwt_scopes waffle switch
The code for this switch was removed in:
https://github.com/edx/edx-platform/pull/23188

BOM-1324
2020-03-04 10:56:52 -05:00
Manjinder Singh
7d2ff9cd3f Removing all settings that have OIDC in name (#23251)
* Removing all settings that have OIDC in name

* Removing ENABLE_DOP_ADAPTER

* changes JWT_ISSUER value in devstack
2020-03-04 09:06:29 -05:00
Feanil Patel
5ec487452d Merge pull request #23188 from edx/robrap/BOM-1324-add-constraint
BOM-1324: remove oauth2.enforce_jwt_scopes toggle
2020-03-02 09:55:35 -05:00
Feanil Patel
54d7743817 Don't iterate over an empty filters list. 2020-02-27 16:32:43 -05:00
Feanil Patel
781629d489 Correct docs and test of restricted JWTs.
The comment is misleading beacuse now that restricted JWTs are enforced
everywhere, we don't need to set the expiry to be in the past for JWT
tokens.
2020-02-27 15:53:48 -05:00
jinder1s
295da79fe5 Remove DOP dispatching from oauth_dispatch.
https://openedx.atlassian.net/browse/BOM-1330
2020-02-27 10:47:06 -05:00
Feanil Patel
fe22e77072 Merge pull request #23199 from edx/robrap/BOM-1292-remove-application-organization
BOM-1292: remove uses of ApplicationOrganization
2020-02-27 10:36:46 -05:00
Robert Raposa
e2cc7fa348 fix failing tests 2020-02-27 09:00:01 -05:00
Robert Raposa
84686e81c3 BOM-1324: remove oauth2.enforce_jwt_scopes toggle
The oauth2.enforce_jwt_scopes waffle switch was added temporarily for
the rollout of jwt scopes. This removes the toggle and replacing code
with the equivalent of `oauth2.enforce_jwt_scopes` as True.
2020-02-27 08:58:45 -05:00
Feanil Patel
4a54967cc5 Replace the ApplicationOrganization in EdxOAuth2AuthorizationView
Move to using the filters list provided in the ApplicationAccess model
to genarically store scopes instead of the org specific ApplicationOrg
model mapping.
2020-02-26 16:02:39 -05:00
Feanil Patel
667df875bd Add back necessary import for ApplicationOrganization. 2020-02-26 11:30:59 -05:00
Feanil Patel
b6104b71fa Deal with linting violations. 2020-02-26 11:29:55 -05:00