Skip to content

Commit b123283

Browse files
authored
Allow non-HTTPS issuer when OAUTHLIB_INSECURE_TRANSPORT. (#803)
* Allow non-HTTPS issuer when OAUTHLIB_INSECURE_TRANSPORT. * Add unit test for validating issuer.
1 parent 2f887b5 commit b123283

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

oauthlib/oauth2/rfc6749/endpoints/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import json
1111
import logging
1212

13-
from .. import grant_types
13+
from .. import grant_types, utils
1414
from .authorization import AuthorizationEndpoint
1515
from .base import BaseEndpoint, catch_errors_and_unavailability
1616
from .introspect import IntrospectEndpoint
@@ -68,7 +68,7 @@ def validate_metadata(self, array, key, is_required=False, is_list=False, is_url
6868
raise ValueError("key {} is a mandatory metadata.".format(key))
6969

7070
elif is_issuer:
71-
if not array[key].startswith("https"):
71+
if not utils.is_secure_transport(array[key]):
7272
raise ValueError("key {}: {} must be an HTTPS URL".format(key, array[key]))
7373
if "?" in array[key] or "&" in array[key] or "#" in array[key]:
7474
raise ValueError("key {}: {} must not contain query or fragment components".format(key, array[key]))

tests/oauth2/rfc6749/endpoints/test_metadata.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,13 @@ def sort_list(claims):
135135
sort_list(metadata.claims)
136136
sort_list(expected_claims)
137137
self.assertEqual(sorted(metadata.claims.items()), sorted(expected_claims.items()))
138+
139+
def test_metadata_validate_issuer(self):
140+
with self.assertRaises(ValueError):
141+
endpoint = TokenEndpoint(
142+
None, None, grant_types={"password": None},
143+
)
144+
metadata = MetadataEndpoint([endpoint], {
145+
"issuer": 'http://foo.bar',
146+
"token_endpoint": "https://foo.bar/token",
147+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy