Repository: svthalia/concrexit

Issue:
Enable OIDC for OAuth
### Is your feature request related to a problem? Please describe.
I want to be able to use OpenID Connect with our OAuth applications and I currently cannot do that.

### Describe the solution you'd like
The toolkit we use has support but needs some config: https://django-oauth-toolkit.readthedocs.io/en/latest/oidc.html

### Motivation
This provides a standardised login flow for clients.

### Describe alternatives you've considered
Using normal OAuth.




Discussion:

Resolving patch:
diff --git a/website/thaliawebsite/settings.py b/website/thaliawebsite/settings.py
--- a/website/thaliawebsite/settings.py
+++ b/website/thaliawebsite/settings.py
@@ -515,12 +515,15 @@ def from_env(
 
 # OAuth configuration
 OAUTH2_PROVIDER = {
+    "OIDC_ENABLED": True,
+    "OIDC_RSA_PRIVATE_KEY": from_env("OIDC_RSA_PRIVATE_KEY", testing=None),
     "ALLOWED_REDIRECT_URI_SCHEMES": setting(
         production=["https", APP_OAUTH_SCHEME],
         staging=["http", "https", APP_OAUTH_SCHEME],
         development=["http", "https", APP_OAUTH_SCHEME],
     ),
     "SCOPES": {
+        "openid": "OpenID Connect",
         "read": "Authenticated read access to the website",
         "write": "Authenticated write access to the website",
         "activemembers:read": "Read access to committee, society and board groups",
diff --git a/website/thaliawebsite/urls.py b/website/thaliawebsite/urls.py
--- a/website/thaliawebsite/urls.py
+++ b/website/thaliawebsite/urls.py
@@ -35,7 +35,13 @@
 from django.urls import path, re_path
 from django.views.i18n import JavaScriptCatalog
 from oauth2_provider.urls import base_urlpatterns
-from oauth2_provider.views import AuthorizedTokensListView, AuthorizedTokenDeleteView
+from oauth2_provider.views import (
+    AuthorizedTokensListView,
+    AuthorizedTokenDeleteView,
+    ConnectDiscoveryInfoView,
+    JwksInfoView,
+    UserInfoView,
+)
 
 from activemembers.sitemaps import sitemap as activemembers_sitemap
 from documents.sitemaps import sitemap as documents_sitemap
@@ -69,13 +75,13 @@
     path("", IndexView.as_view(), name="index"),
     # Default helpers
     path(
-        "user/",
+        "",
         include(
-            [
-                path(
-                    "oauth/",
-                    include(
-                        (
+            (
+                [
+                    path(
+                        "user/oauth/",
+                        include(
                             base_urlpatterns
                             + [
                                 path(
@@ -88,12 +94,30 @@
                                     AuthorizedTokenDeleteView.as_view(),
                                     name="authorized-token-delete",
                                 ),
-                            ],
-                            "oauth2_provider",
+                                path(
+                                    "keys/", JwksInfoView.as_view(), name="jwks-info",
+                                ),
+                                path(
+                                    "info/", UserInfoView.as_view(), name="user-info",
+                                ),
+                            ]
                         ),
-                        namespace="oauth2_provider",
                     ),
-                ),
+                    path(
+                        ".well-known/openid-configuration/",
+                        ConnectDiscoveryInfoView.as_view(),
+                        name="oidc-connect-discovery-info",
+                    ),
+                ],
+                "oauth2_provider",
+            ),
+            namespace="oauth2_provider",
+        ),
+    ),
+    path(
+        "user/",
+        include(
+            [
                 path(
                     "login/",
                     LoginView.as_view(


Test patch: