All Projects → openedx → auth-backends

openedx / auth-backends

Licence: AGPL-3.0 license
Custom authentication backends and views for edX services

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to auth-backends

example-oidc
OIDC (OpenID Connect) Example for http://openid.net/connect/
Stars: ✭ 221 (+1005%)
Mutual labels:  openid-connect, oidc
aws-cdk-github-oidc
CDK constructs to use OpenID Connect for authenticating your Github Action workflow with AWS IAM
Stars: ✭ 59 (+195%)
Mutual labels:  openid-connect, oidc
oidc
Easy to use OpenID Connect client and server library written for Go and certified by the OpenID Foundation
Stars: ✭ 475 (+2275%)
Mutual labels:  openid-connect, oidc
sotsera.blazor.oidc
OpenID Connect client for Blazor client-side projects
Stars: ✭ 21 (+5%)
Mutual labels:  openid-connect, oidc
Hydra
OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Compatible with MITREid.
Stars: ✭ 11,884 (+59320%)
Mutual labels:  openid-connect, oidc
mock-oauth2-server
A scriptable/customizable web server for testing HTTP clients using OAuth2/OpenID Connect or applications with a dependency to a running OAuth2 server (i.e. APIs requiring signed JWTs from a known issuer)
Stars: ✭ 83 (+315%)
Mutual labels:  openid-connect, oidc
go-oidc-middleware
OpenID Connect (OIDC) http middleware for Go
Stars: ✭ 65 (+225%)
Mutual labels:  openid-connect, oidc
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+14170%)
Mutual labels:  openid-connect, oidc
Node Oidc Provider
OpenID Certified™ OAuth 2.0 Authorization Server implementation for Node.js
Stars: ✭ 2,018 (+9990%)
Mutual labels:  openid-connect, oidc
oidc-agent
oidc-agent for managing OpenID Connect tokens on the command line
Stars: ✭ 47 (+135%)
Mutual labels:  openid-connect, oidc
Oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
Stars: ✭ 2,323 (+11515%)
Mutual labels:  openid-connect, oidc
AspNetCore6Experiments
ASP.NET Core Blazor BFF with Azure AD and Razor page
Stars: ✭ 43 (+115%)
Mutual labels:  openid-connect, oidc
stanford-algorithms-specialization
Problem Set and Programming Assignment Solutions to Stanford University's Algorithms Specialization on Coursera & edX
Stars: ✭ 43 (+115%)
Mutual labels:  edx
token-cli
Command line utility for interacting with OAuth2 infrastructure to generate tokens
Stars: ✭ 19 (-5%)
Mutual labels:  oidc
discourse-edx-lti
Discourse plugin for using Discourse as a discussion forum in EdX courses
Stars: ✭ 19 (-5%)
Mutual labels:  edx
configuration
A collection of edx configuration scripts and utilities that edx.org uses to deploy openedx.
Stars: ✭ 814 (+3970%)
Mutual labels:  edx
dex-operator
A Kubernetes operator for Dex
Stars: ✭ 16 (-20%)
Mutual labels:  oidc
ms-identity-javascript-tutorial
A chapterwise tutorial that will take you through the fundamentals of modern authentication with Microsoft identity platform in Vanilla JavaScript.
Stars: ✭ 100 (+400%)
Mutual labels:  oidc
edx-app-android
The Open edX mobile app for Android!
Stars: ✭ 282 (+1310%)
Mutual labels:  edx
edx-app-ios
The Open edX mobile app for iOS!
Stars: ✭ 216 (+980%)
Mutual labels:  edx

auth-backends CI Codecov

This package contains custom authentication backends, views, and pipeline steps used by edX services for single sign-on.

This package is compatible with Python 3.8, Django 2.2 and Django 3.0

We currently support OAuth 2.0 authentication. Support for OpenID Connect (OIDC) was removed as of version 3.0. Use version 2.x if you require OIDC and are not able to migrate to OAuth2.

Installation

The auth_backends package can be installed from PyPI using pip:

$ pip install edx-auth-backends

Update INSTALLED_APPS:

INSTALLED_APPS = (
    'social_django',
)

Configuration

Adding single sign-on/out support to a service requires a few changes:

  1. Define settings
  2. Add the authentication backend
  3. Add the login/logout redirects

OAuth 2.0 Settings

Setting Purpose
SOCIAL_AUTH_EDX_OAUTH2_KEY Client key
SOCIAL_AUTH_EDX_OAUTH2_SECRET Client secret
SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT LMS root, reachable from the application server (e.g. https://courses.stage.edx.org or http://edx.devstack.lms:18000)
SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT LMS root, reachable from the end user's browser (e.g. https://courses.stage.edx.org or http://localhost:18000)
SOCIAL_AUTH_EDX_OAUTH2_JWS_HMAC_SIGNING_KEY (Optional) Shared secret for JWT signed with HS512 algorithm
SOCIAL_AUTH_EDX_OAUTH2_PROVIDER_CONFIGURATION_CACHE_TTL (Optional) Cache timeout for provider configuration. Defaults to 1 week.
SOCIAL_AUTH_EDX_OAUTH2_JWKS_CACHE_TTL (Optional) Cache timeout for provider's JWKS key data. Defaults to 1 day.

OAuth2 Applications require access to the user_id scope in order for the EdXOAuth2 backend to work. The backend will write the user_id into the social-auth extra_data, and can be accessed within the User model as follows:

self.social_auth.first().extra_data[u'user_id']  # pylint: disable=no-member

Strategy

We use a custom strategy that includes many of the default settings necessary to utilize single sign-on for edX services. This strategy should be used for all services to simplify configuration. If you need to override the defaults, you may still do so as you would with any social auth setting——prepend SOCIAL_AUTH_ to the setting name. Add the following to your Django settings to use the strategy:

SOCIAL_AUTH_STRATEGY = 'auth_backends.strategies.EdxDjangoStrategy'

Authentication Backend

Configuring the backend is simply a matter of updating the AUTHENTICATION_BACKENDS setting. The configuration below is sufficient for all edX services.

AUTHENTICATION_BACKENDS = (
    'auth_backends.backends.EdXOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

Authentication Views

In order to make use of the authentication backend, your service's login/logout views need to be updated. The login view should be updated to redirect to the authentication provider's login page. The logout view should be updated to redirect to the authentication provider's logout page.

This package includes views and urlpatterns configured for OAuth 2.0. To use them, simply append/prepend oauth2_urlpatterns to your service's urlpatterns in urls.py.

from auth_backends.urls import oauth2_urlpatterns

urlpatterns = oauth2_urlpatterns + [
    url(r'^admin/', include(admin.site.urls)),
    ...
]

It is recommended that you not modify the login view. If, however, you need to modify the logout view (to redirect to a different URL, for example), you can subclass EdxOAuth2LogoutView for the view and LogoutViewTestMixin for your tests.

Testing

Call make test.

Publishing a Release

After a PR merges, create a new tag from master branch with a new version of the package and create a Github release using the new tag that will automatically publish the package to PyPi when a release is created.

License

The code in this repository is licensed under the AGPL unless otherwise noted.

Please see LICENSE.txt for details.

How To Contribute

Contributions are very welcome!

Please read How To Contribute for details.

Even though it was written with edx-platform in mind, the guidelines should be followed for Open edX code in general.

Reporting Security Issues

Please do not report security issues in public. Please email [email protected].

Mailing List and IRC Channel

You can discuss this code on the edx-code Google Group or in the #edx-code IRC channel on Freenode.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].