Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 4d19bbab authored by Patrick Steffes's avatar Patrick Steffes
Browse files

import from settings.py

parent 3d08c082
......@@ -13,7 +13,7 @@ pip install git+https://gitlab.umich.edu/its-inf-iam/drf_simplejwt_with_oidc.git
Follow the djangorestframework-simplejwt [Getting Started](https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html) guide for the base django configuration.
The only change necessary is to update the urls.py configuration to import this packages OIDCTokenObtainPairView as follows.
Update the urls.py configuration to import this packages OIDCTokenObtainPairView as follows.
```py
from django.urls import include, path
......@@ -26,6 +26,13 @@ urlpatterns = [
]
```
Set the following in settings.py
```py
OIDC_USERINFO_URL
OIDC_USERINFO_TIMEOUT
```
## Usage
The token endpoint replaces basic auth and expects an `idp_access_token`
......
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import BaseBackend
from rest_framework import exceptions
import logging
import requests
logger = logging.getLogger(__name__)
UserModel = get_user_model()
......@@ -18,13 +17,12 @@ class OIDCTokenBackend(BaseBackend):
Returns a 'User' if a correct access_token has been supplied
after verifying via the OIDC UserInfo endpoint.
"""
logger.info(f'request={request} iat={idp_access_token}')
try:
response = requests.get(
'https://shib-idp-staging.dsc.umich.edu/idp/profile/oidc/userinfo',
settings.OIDC_USERINFO_URL,
headers = {'Authorization': f'Bearer {idp_access_token}'},
timeout=5,
timeout=settings.OIDC_USERINFO_TIMEOUT,
)
response.raise_for_status()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment