Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-HTTPS issuer when OAUTHLIB_INSECURE_TRANSPORT. #803

Merged
merged 2 commits into from Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions oauthlib/oauth2/rfc6749/endpoints/metadata.py
Expand Up @@ -10,7 +10,7 @@
import json
import logging

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

elif is_issuer:
if not array[key].startswith("https"):
if not utils.is_secure_transport(array[key]):
raise ValueError("key {}: {} must be an HTTPS URL".format(key, array[key]))
if "?" in array[key] or "&" in array[key] or "#" in array[key]:
raise ValueError("key {}: {} must not contain query or fragment components".format(key, array[key]))
Expand Down
10 changes: 10 additions & 0 deletions tests/oauth2/rfc6749/endpoints/test_metadata.py
Expand Up @@ -135,3 +135,13 @@ def sort_list(claims):
sort_list(metadata.claims)
sort_list(expected_claims)
self.assertEqual(sorted(metadata.claims.items()), sorted(expected_claims.items()))

def test_metadata_validate_issuer(self):
with self.assertRaises(ValueError):
endpoint = TokenEndpoint(
None, None, grant_types={"password": None},
)
metadata = MetadataEndpoint([endpoint], {
"issuer": 'http://foo.bar',
"token_endpoint": "https://foo.bar/token",
})