-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed OIDC authentication for SCIM endpoints
Previously, the Coldfront SCIM endpoints could not perform OIDC authentication, preventing usage of the client credentials and device authorization flows. A authentication middleware which subclasses from the one provided by `django_scim` has been added, which will perform OIDC authentication given an access token in the "Authorization" HTTP request header. The SCIM endpoint is now available to Coldfront users with "staff" or "superuser" status. It will perform OIDC authentication if the `PLUGIN_AUTH_OIDC` env var is set to True.
- Loading branch information
Showing
3 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import logging | ||
|
||
from django_scim.middleware import SCIMAuthCheckMiddleware | ||
from mozilla_django_oidc.contrib.drf import OIDCAuthentication | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class SCIMColdfrontAuthCheckMiddleware(SCIMAuthCheckMiddleware): | ||
def process_request(self, request): | ||
if not request.user or not request.user.is_staff: | ||
# PLUGIN_AUTH_OIDC implies DRF OIDC backend is configured | ||
if os.getenv("PLUGIN_AUTH_OIDC") == "True": | ||
oidc_auth_obj = OIDCAuthentication() | ||
request.user = oidc_auth_obj.authenticate(request) | ||
return super().process_request(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters