Skip to content

[FC-0118] docs: add ADR for standardizing authentication patterns#38301

Open
Faraz32123 wants to merge 12 commits into
docs/ADRs-axim_api_improvementsfrom
docs/ADR-standardize_authentication_patterns_and_security_scheme_usage
Open

[FC-0118] docs: add ADR for standardizing authentication patterns#38301
Faraz32123 wants to merge 12 commits into
docs/ADRs-axim_api_improvementsfrom
docs/ADR-standardize_authentication_patterns_and_security_scheme_usage

Conversation

@Faraz32123

@Faraz32123 Faraz32123 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

related issue: #38169

@Faraz32123

Copy link
Copy Markdown
Contributor Author

related doc worth reading: https://docs.openedx.org/projects/openedx-proposals/en/latest/best-practices/oep-0042-bp-authentication.html#consequences, we can make changes to the ADR based on the attached doc if needed.

@Faraz32123 Faraz32123 requested a review from feanil April 8, 2026 08:29
@Faraz32123 Faraz32123 changed the title docs: add ADR for standardizing authentication patterns [FC-0118] docs: add ADR for standardizing authentication patterns Apr 13, 2026
@Faraz32123 Faraz32123 force-pushed the docs/ADR-standardize_authentication_patterns_and_security_scheme_usage branch from f5cb0c1 to a6a25d3 Compare April 13, 2026 08:40
Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
@Faraz32123 Faraz32123 requested a review from feanil April 20, 2026 10:15
authentication mechanism for all API access** (external and internal), per `OEP-0042`_
2. **``BearerAuthentication`` and ``BearerAuthenticationAllowInactiveUser`` are
deprecated and MUST NOT be used in new code**
3. **Session authentication MUST be used only for browser-based UI interactions**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this distinction is super important. What is the bad thing that happens if your API endpoints support session auth also? Right now DRF in openedx-platform supports both by default: https://github.com/openedx/openedx-platform/blob/master/openedx/envs/common.py#L822-L825 and I don't see a problem with that. I think it's more valuable that all endpoints support any valid auth scheme than having API calls not support the browser.

@Faraz32123 Faraz32123 Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feanil I think you have valid point here that we should support any valid auth scheme instead of categorizing them on the basis of their usage.
I am adding a new commit that addresses above point with some additional remains(includes removal of JWT issuers & use of asymmetric keys) of OEP-0042, But it had some consequences(Link) that you might want to look in. That way we can decide the scope of this ADR. And we can remove the part that is not needed for this ADR accordingly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line is still worth updating to say that both JWT and Session auth are okay but other deprectaed authentication schemes such as bearer are not. What do you think. That way this aligns with the cleanup we want to do.

Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
@robrap

robrap commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@feanil: You should review openedx/edx-drf-extensions#284 and all its comments to see if you are missing anything, and you may want to reference it in this ADR.

@Faraz32123 Faraz32123 force-pushed the docs/ADR-standardize_authentication_patterns_and_security_scheme_usage branch 2 times, most recently from 7504911 to 0ed80d7 Compare May 5, 2026 14:11

@robrap robrap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional thoughts. Thanks.

Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst
Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
@Faraz32123 Faraz32123 requested a review from robrap May 7, 2026 09:55
@@ -0,0 +1,196 @@
Standardize Authentication Patterns and Security Schemes
========================================================

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other auth ADRs (0003, 0008, 0009, 0010, 0013, 0014) live under openedx/core/djangoapps/oauth_dispatch/docs/decisions/. Add a pointer file there linking to this one.


1. **JWT authentication via** ``JwtAuthentication`` **MUST be the standard
authentication mechanism for all API(external and internal) access**, per `OEP-0042`_
2. **Session authentication MUST also be used when** the expected client for an API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"For all API access" would include admin views, /oauth2/access_token/, and HMAC/webhook endpoints — none of which use JwtAuthentication. Narrow this to "DRF API endpoints that take user-authenticated requests" and list the exclusions for context.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feanil: Would another way to say user-authenticated requests be password-authenticated or user-password-authenticated? I wasn't clear at first.

As an aside, for Mobile Authentication, there were some endpoints that will accept JwtAuthentication only if it has grant type password.

Comment thread docs/decisions/0034-unify-auth-oauth2-dot-v2.rst Outdated
Comment on lines +118 to +121
authentication_classes = (
JwtAuthentication,
SessionAuthenticationAllowInactiveUser,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the target state should be not overriding the platform Defaults set in the settings files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SessionAuthentication and SessionAuthenticationAllowInactiveUser are different. If an endpoint only need JwtAuthentication & SessionAuthentication, then there's no need to add authentication_classes in an endpoint. What do u think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, ok, yes for places that are currently using SessionAuthenticationAllowInactiveUser we'll need to leave them as is as that would be a breaking change, we'll need to deal with that later. That's fine.

@Faraz32123 Faraz32123 force-pushed the docs/ADR-standardize_authentication_patterns_and_security_scheme_usage branch from 03f1004 to 4d6afa4 Compare June 10, 2026 08:17
@Faraz32123 Faraz32123 requested a review from feanil June 10, 2026 09:52
@Faraz32123 Faraz32123 force-pushed the docs/ADRs-axim_api_improvements branch 2 times, most recently from adf2e7b to ad4b7ba Compare June 10, 2026 10:51
@Faraz32123 Faraz32123 force-pushed the docs/ADR-standardize_authentication_patterns_and_security_scheme_usage branch from 9ad4526 to 6c35624 Compare June 17, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants