Skip to content

Commit 36bcbf2

Browse files
committed
feat: update test idp to use new cors
1 parent 2c83e6c commit 36bcbf2

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

tests/app/idp/idp/apps.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.apps import AppConfig
2+
from corsheaders.signals import check_request_enabled
3+
4+
def cors_allow_origin(sender, request, **kwargs):
5+
return request.path == "/o/userinfo/" or request.path == "/o/userinfo"
6+
7+
class IDPAppConfig(AppConfig):
8+
name = "idp"
9+
default = True
10+
11+
def ready(self):
12+
check_request_enabled.connect(cors_allow_origin)

tests/app/idp/idp/settings.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
https://docs.djangoproject.com/en/4.2/ref/settings/
1111
"""
1212

13+
import os
1314
from pathlib import Path
1415

1516

@@ -32,6 +33,7 @@
3233
# Application definition
3334

3435
INSTALLED_APPS = [
36+
"idp.apps.IDPAppConfig",
3537
"django.contrib.admin",
3638
"django.contrib.auth",
3739
"django.contrib.contenttypes",
@@ -186,10 +188,10 @@
186188
"SCOPES": {
187189
"openid": "OpenID Connect scope",
188190
},
191+
'ALLOWED_SCHEMES': ['https', 'http'],
189192
}
190-
191-
# just for this example
192-
CORS_ORIGIN_ALLOW_ALL = True
193+
# needs to be set to allow cors requests from the test app, along with ALLOWED_SCHEMES=["http"]
194+
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
193195

194196
LOGGING = {
195197
"version": 1,
@@ -210,5 +212,11 @@
210212
"level": "DEBUG",
211213
"propagate": False,
212214
},
215+
# occasionally you may want to see what's going on in upstream in oauthlib
216+
# "oauthlib": {
217+
# "handlers": ["console"],
218+
# "level": "DEBUG",
219+
# "propagate": False,
220+
# },
213221
},
214222
}

0 commit comments

Comments
 (0)