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

(insecure_transport) OAuth 2 MUST utilize https. #59

Closed
higuchi-toshio-intec opened this issue Aug 3, 2022 · 3 comments
Closed

(insecure_transport) OAuth 2 MUST utilize https. #59

higuchi-toshio-intec opened this issue Aug 3, 2022 · 3 comments

Comments

@higuchi-toshio-intec
Copy link

Very thanks for your project.

My execution environment is built with these versions.

  • AWS Fargate
    • CKAN [2.9.5]
    • ckanext-oauth2 [0.7.0]
  • Amazon ELB (for "https" front-end listener)
  • Amazon Cognito

On my execution environment, I got a error.
ckanext-oauth2-insecure

I tried to fix it.
I hope you like the following.

diff --git a/ckanext/oauth2/oauth2.py b/ckanext/oauth2/oauth2.py
index 28a2724..cc9c782 100644
--- a/ckanext/oauth2/oauth2.py
+++ b/ckanext/oauth2/oauth2.py
@@ -115,10 +115,14 @@ class OAuth2Helper(object):
             )
 
         try:
+            req_url = toolkit.request.url
+            ckan_site_url = os.environ.get('CKAN_SITE_URL')
+            if (ckan_site_url.startswith("https:")):
+                req_url = req_url.replace("http:", "https:")
             token = oauth.fetch_token(self.token_endpoint,
                                       headers=headers,
                                       client_secret=self.client_secret,
-                                      authorization_response=toolkit.request.url,
+                                      authorization_response=req_url,
                                       verify=self.verify_https)
         except requests.exceptions.SSLError as e:
             # TODO search a better way to detect invalid certificates

regards

@aitormagan
Copy link
Contributor

aitormagan commented Aug 3, 2022 via email

@higuchi-toshio-intec
Copy link
Author

Hi,

I want to use secure transport.

I installed CKAN from Docker Compose.
It supports "http" only.
Then using Amazon ELB for "https" front-end listener.

Please image this.

Cognito <== https ==> Amazon ELB [ (inside AWS) <== http ==> CKAN(docker) ]

In this case,
Shouldn't CKAN (docker) redirect 'https' addresses?

@frafra
Copy link

frafra commented Aug 14, 2022

This is an issue with your CKAN setup; I would suggest look for help there.
Have you used https:// for CKAN_SITE_URL?
Have you looked at the previous issues? #44.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants