Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Hiroki Kiyohara
Jens Timmerman
Jerome Leclanche
Jim Graham
Jonas Nygaard Pedersen
Jonathan Steffan
Jun Zhou
Kristian Rune Larsen
Expand Down
12 changes: 8 additions & 4 deletions oauth2_provider/views/oidc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from urllib.parse import urlparse

from django.http import HttpResponse, JsonResponse
from django.urls import reverse
Expand Down Expand Up @@ -32,12 +33,15 @@ def get(self, request, *args, **kwargs):
)
jwks_uri = request.build_absolute_uri(reverse("oauth2_provider:jwks-info"))
else:
authorization_endpoint = "{}{}".format(issuer_url, reverse("oauth2_provider:authorize"))
token_endpoint = "{}{}".format(issuer_url, reverse("oauth2_provider:token"))
parsed_url = urlparse(oauth2_settings.OIDC_ISS_ENDPOINT)
host = parsed_url.scheme + "://" + parsed_url.netloc
authorization_endpoint = "{}{}".format(host, reverse("oauth2_provider:authorize"))
token_endpoint = "{}{}".format(host, reverse("oauth2_provider:token"))
userinfo_endpoint = oauth2_settings.OIDC_USERINFO_ENDPOINT or "{}{}".format(
issuer_url, reverse("oauth2_provider:user-info")
host, reverse("oauth2_provider:user-info")
)
jwks_uri = "{}{}".format(issuer_url, reverse("oauth2_provider:jwks-info"))
jwks_uri = "{}{}".format(host, reverse("oauth2_provider:jwks-info"))

signing_algorithms = [Application.HS256_ALGORITHM]
if oauth2_settings.OIDC_RSA_PRIVATE_KEY:
signing_algorithms = [Application.RS256_ALGORITHM, Application.HS256_ALGORITHM]
Expand Down
4 changes: 2 additions & 2 deletions tests/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
DEFAULT_SCOPES_RO = {"DEFAULT_SCOPES": ["read"]}
OIDC_SETTINGS_RW = {
"OIDC_ENABLED": True,
"OIDC_ISS_ENDPOINT": "http://localhost",
"OIDC_USERINFO_ENDPOINT": "http://localhost/userinfo/",
"OIDC_ISS_ENDPOINT": "http://localhost/o",
"OIDC_USERINFO_ENDPOINT": "http://localhost/o/userinfo/",
"OIDC_RSA_PRIVATE_KEY": settings.OIDC_RSA_PRIVATE_KEY,
"SCOPES": {
"read": "Reading scope",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_oidc_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
class TestConnectDiscoveryInfoView(TestCase):
def test_get_connect_discovery_info(self):
expected_response = {
"issuer": "http://localhost",
"issuer": "http://localhost/o",
"authorization_endpoint": "http://localhost/o/authorize/",
"token_endpoint": "http://localhost/o/token/",
"userinfo_endpoint": "http://localhost/userinfo/",
"userinfo_endpoint": "http://localhost/o/userinfo/",
"jwks_uri": "http://localhost/o/.well-known/jwks.json",
"response_types_supported": [
"code",
Expand Down