Skip to content

Commit

Permalink
feat: update test idp to use new cors (#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
dopry committed Oct 20, 2023
1 parent 2c83e6c commit 584627d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
14 changes: 14 additions & 0 deletions tests/app/idp/idp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from corsheaders.signals import check_request_enabled
from django.apps import AppConfig


def cors_allow_origin(sender, request, **kwargs):
return request.path == "/o/userinfo/" or request.path == "/o/userinfo"


class IDPAppConfig(AppConfig):
name = "idp"
default = True

def ready(self):
check_request_enabled.connect(cors_allow_origin)
14 changes: 11 additions & 3 deletions tests/app/idp/idp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

import os
from pathlib import Path


Expand All @@ -32,6 +33,7 @@
# Application definition

INSTALLED_APPS = [
"idp.apps.IDPAppConfig",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand Down Expand Up @@ -186,10 +188,10 @@
"SCOPES": {
"openid": "OpenID Connect scope",
},
"ALLOWED_SCHEMES": ["https", "http"],
}

# just for this example
CORS_ORIGIN_ALLOW_ALL = True
# needs to be set to allow cors requests from the test app, along with ALLOWED_SCHEMES=["http"]
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

LOGGING = {
"version": 1,
Expand All @@ -210,5 +212,11 @@
"level": "DEBUG",
"propagate": False,
},
# occasionally you may want to see what's going on in upstream in oauthlib
# "oauthlib": {
# "handlers": ["console"],
# "level": "DEBUG",
# "propagate": False,
# },
},
}

0 comments on commit 584627d

Please sign in to comment.