Skip to content

Commit

Permalink
Add OAuth provider
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethjiang committed Jan 8, 2024
1 parent ddebaac commit f9e6dbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def get_bool(key, default):
'qr_code',
'app', # app has to come before allauth for template override to work
"channels_presence",
'oauth2_provider',
'allauth',
'allauth.account',
'allauth.socialaccount',
Expand Down Expand Up @@ -275,6 +276,7 @@ def get_bool(key, default):

# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
'oauth2_provider.backends.OAuth2Backend',
)
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_EMAIL_REQUIRED = True
Expand Down Expand Up @@ -302,6 +304,12 @@ def get_bool(key, default):
if RECAPTCHA_SITE_KEY:
ACCOUNT_FORMS = {'signup': 'app.forms.RecaptchaSignupForm'}

OAUTH2_PROVIDER = {
'ACCESS_TOKEN_EXPIRE_SECONDS': None,
'SCOPES': {'read': 'Read scope', 'write': 'Write scope'},
'PKCE_REQUIRED': False,
}

# Layout
TEMPLATE_LAYOUT = "layout.html"

Expand Down
1 change: 1 addition & 0 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
urlpatterns = [
path('', include('app.urls')),
path('accounts/', include('allauth.urls')),
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
path('api/', include('api.urls')),
path('admin/', admin.site.urls),
]
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,4 @@ websocket-client==1.6.4 ; python_version >= '3.8'
whitenoise[brotli]==6.6.0
yarl==1.9.2 ; python_version >= '3.7'
zope.interface==6.1
django-oauth-toolkit==2.3.0

0 comments on commit f9e6dbe

Please sign in to comment.