From 045bd3de983ae5516d532b2d295b79242fecde03 Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Tue, 13 Oct 2020 14:12:55 -0400 Subject: [PATCH 01/12] Updated oauth import to avoid deprecation warning --- jwql/website/apps/jwql/oauth.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index 70167c088..0d934c4c1 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -41,7 +41,7 @@ def login(request): import os import requests -from authlib.django.client import OAuth +from authlib.integrations.django_client import OAuth from django.shortcuts import redirect, render import jwql @@ -76,9 +76,7 @@ def register_oauth(): 'mast_auth', client_id='{}'.format(client_id), client_secret='{}'.format(client_secret), - access_token_url='https://{}/oauth/access_token?client_secret={}'.format( - auth_mast, client_secret - ), + access_token_url='https://{}/oauth/access_token?client_secret={}'.format(auth_mast, client_secret), access_token_params=None, refresh_token_url=None, authorize_url='https://{}/oauth/authorize'.format(auth_mast), @@ -108,7 +106,10 @@ def authorize(request): Outgoing response sent to the webpage """ + print(request) + # Get auth.mast token + print(JWQL_OAUTH.__dict__) token = JWQL_OAUTH.mast_auth.authorize_access_token( request, headers={'Accept': 'application/json'} ) From f7eaac8458197d0c9c77fdc10dd5d9ec4283714f Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Wed, 14 Oct 2020 16:50:48 -0400 Subject: [PATCH 02/12] Updating based on slightly modified MAST api --- jwql/website/apps/jwql/oauth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index 0d934c4c1..d7f5d3373 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -76,7 +76,7 @@ def register_oauth(): 'mast_auth', client_id='{}'.format(client_id), client_secret='{}'.format(client_secret), - access_token_url='https://{}/oauth/access_token?client_secret={}'.format(auth_mast, client_secret), + access_token_url='https://{}/oauth/token'.format(auth_mast), access_token_params=None, refresh_token_url=None, authorize_url='https://{}/oauth/authorize'.format(auth_mast), From e231d9eb1301449efba81c74f4ade6843d979d76 Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Thu, 15 Oct 2020 11:06:13 -0400 Subject: [PATCH 03/12] Added some client_kwargs --- jwql/website/apps/jwql/oauth.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index d7f5d3373..b330cf87e 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -71,7 +71,10 @@ def register_oauth(): # Register with auth.mast oauth = OAuth() - client_kwargs = {'scope': 'mast:user:info'} + client_kwargs = { + 'scope': 'mast:user:info', + 'token_endpoint_auth_method': 'client_secret_basic', + 'token_placement': 'header'} oauth.register( 'mast_auth', client_id='{}'.format(client_id), @@ -85,6 +88,8 @@ def register_oauth(): return oauth + nd'token_placement': 'header', + JWQL_OAUTH = register_oauth() From ab3b120587caa8b32b616ab2be762af13103736a Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Thu, 15 Oct 2020 11:16:18 -0400 Subject: [PATCH 04/12] Cleaned up some text that was not removed --- jwql/website/apps/jwql/oauth.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index b330cf87e..63bd58fbb 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -88,8 +88,6 @@ def register_oauth(): return oauth - nd'token_placement': 'header', - JWQL_OAUTH = register_oauth() From 6a7aa6ac4cfe3328707c57c92b9a52d06da6111f Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Thu, 15 Oct 2020 16:37:39 -0400 Subject: [PATCH 05/12] Fixed redirect uri --- jwql/website/apps/jwql/oauth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index 63bd58fbb..f01648a7b 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -41,7 +41,8 @@ def login(request): import os import requests -from authlib.integrations.django_client import OAuth +#from authlib.integrations.django_client import OAuth +from authlib.django.client import OAuth from django.shortcuts import redirect, render import jwql @@ -263,7 +264,7 @@ def login(request, user): # Redirect to oauth login global PREV_PAGE PREV_PAGE = request.META.get('HTTP_REFERER') - redirect_uri = os.path.join(get_base_url(), 'authorize') + redirect_uri = os.path.join('https://dljwql.stsci.edu/authorize') return JWQL_OAUTH.mast_auth.authorize_redirect(request, redirect_uri) From f23a04bbca8bd4399dc0f1d8d4496bd51af42c7a Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Thu, 15 Oct 2020 17:03:31 -0400 Subject: [PATCH 06/12] Upgrading to authlib 0.15 --- environment_python_3_6.yml | 2 +- environment_python_3_7.yml | 2 +- environment_python_3_8.yml | 2 +- jwql/website/apps/jwql/oauth.py | 7 ++----- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/environment_python_3_6.yml b/environment_python_3_6.yml index 7ce8fd7ca..5578e9a6c 100644 --- a/environment_python_3_6.yml +++ b/environment_python_3_6.yml @@ -31,7 +31,7 @@ dependencies: - pip: - asdf==2.7.1 - astropy==4.0.1 - - authlib==0.14.3 + - authlib==0.15.1 - codecov==2.1.9 - crds==10.0.0 - jwedb>=0.0.3 diff --git a/environment_python_3_7.yml b/environment_python_3_7.yml index 3896ed0b5..4a016826a 100644 --- a/environment_python_3_7.yml +++ b/environment_python_3_7.yml @@ -30,7 +30,7 @@ dependencies: - pip: - asdf==2.7.1 - astropy==4.0.1.post1 - - authlib==0.14.3 + - authlib==0.15.1 - codecov==2.1.9 - crds==10.0.0 - jwedb==0.0.6 diff --git a/environment_python_3_8.yml b/environment_python_3_8.yml index fae30a4ed..92ef58508 100644 --- a/environment_python_3_8.yml +++ b/environment_python_3_8.yml @@ -27,7 +27,7 @@ dependencies: - asdf==2.7.1 - astropy==4.0.1.post1 - astroquery==0.4.1 - - authlib==0.14.3 + - authlib==0.15.1 - bokeh>=1.0,<1.4 - codecov==2.1.9 - crds==10.0.0 diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index f01648a7b..addf90029 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -8,6 +8,7 @@ - Matthew Bourque - Christian Mesh + - Ben Falk Use --- @@ -41,8 +42,7 @@ def login(request): import os import requests -#from authlib.integrations.django_client import OAuth -from authlib.django.client import OAuth +from authlib.integrations.django_client import OAuth from django.shortcuts import redirect, render import jwql @@ -110,10 +110,7 @@ def authorize(request): Outgoing response sent to the webpage """ - print(request) - # Get auth.mast token - print(JWQL_OAUTH.__dict__) token = JWQL_OAUTH.mast_auth.authorize_access_token( request, headers={'Accept': 'application/json'} ) From 3a36d57ae0bbad830dbdbdc1d4bbc26088bd4de6 Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Thu, 15 Oct 2020 17:10:31 -0400 Subject: [PATCH 07/12] Reverting back to authlib 0.10 --- jwql/website/apps/jwql/oauth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index addf90029..f023715dd 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -42,7 +42,8 @@ def login(request): import os import requests -from authlib.integrations.django_client import OAuth +#from authlib.integrations.django_client import OAuth +from authlib.django.client import OAuth from django.shortcuts import redirect, render import jwql From fa5fc3f6fa5d337a64511cb70eaef2ffd5dfea2b Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Thu, 15 Oct 2020 17:42:38 -0400 Subject: [PATCH 08/12] Settling on version 0.14.3. 0.10 is too old, and 0.15 crashes with dependency issues --- environment_python_3_6.yml | 2 +- environment_python_3_7.yml | 2 +- environment_python_3_8.yml | 2 +- jwql/website/apps/jwql/oauth.py | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/environment_python_3_6.yml b/environment_python_3_6.yml index 5578e9a6c..7ce8fd7ca 100644 --- a/environment_python_3_6.yml +++ b/environment_python_3_6.yml @@ -31,7 +31,7 @@ dependencies: - pip: - asdf==2.7.1 - astropy==4.0.1 - - authlib==0.15.1 + - authlib==0.14.3 - codecov==2.1.9 - crds==10.0.0 - jwedb>=0.0.3 diff --git a/environment_python_3_7.yml b/environment_python_3_7.yml index 4a016826a..3896ed0b5 100644 --- a/environment_python_3_7.yml +++ b/environment_python_3_7.yml @@ -30,7 +30,7 @@ dependencies: - pip: - asdf==2.7.1 - astropy==4.0.1.post1 - - authlib==0.15.1 + - authlib==0.14.3 - codecov==2.1.9 - crds==10.0.0 - jwedb==0.0.6 diff --git a/environment_python_3_8.yml b/environment_python_3_8.yml index 92ef58508..fae30a4ed 100644 --- a/environment_python_3_8.yml +++ b/environment_python_3_8.yml @@ -27,7 +27,7 @@ dependencies: - asdf==2.7.1 - astropy==4.0.1.post1 - astroquery==0.4.1 - - authlib==0.15.1 + - authlib==0.14.3 - bokeh>=1.0,<1.4 - codecov==2.1.9 - crds==10.0.0 diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index f023715dd..addf90029 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -42,8 +42,7 @@ def login(request): import os import requests -#from authlib.integrations.django_client import OAuth -from authlib.django.client import OAuth +from authlib.integrations.django_client import OAuth from django.shortcuts import redirect, render import jwql From 329cffe4376d0bd0e9632773435140be43f49bb5 Mon Sep 17 00:00:00 2001 From: Ben Falk Date: Fri, 16 Oct 2020 11:53:49 -0400 Subject: [PATCH 09/12] authorize_access_token doesn't need headers argument --- jwql/website/apps/jwql/oauth.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index addf90029..6330b4dc3 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -111,9 +111,7 @@ def authorize(request): """ # Get auth.mast token - token = JWQL_OAUTH.mast_auth.authorize_access_token( - request, headers={'Accept': 'application/json'} - ) + token = JWQL_OAUTH.mast_auth.authorize_access_token(request) # Determine domain base_url = get_base_url() From 2a1856529a885eefd79e82d42dc06159991e6d36 Mon Sep 17 00:00:00 2001 From: Ben Falk Date: Fri, 16 Oct 2020 12:22:11 -0400 Subject: [PATCH 10/12] build the absolute uri from utility functions --- jwql/website/apps/jwql/oauth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jwql/website/apps/jwql/oauth.py b/jwql/website/apps/jwql/oauth.py index 6330b4dc3..281aed344 100644 --- a/jwql/website/apps/jwql/oauth.py +++ b/jwql/website/apps/jwql/oauth.py @@ -44,6 +44,7 @@ def login(request): from authlib.integrations.django_client import OAuth from django.shortcuts import redirect, render +from django.urls import reverse import jwql from jwql.utils.constants import MONITORS @@ -259,7 +260,7 @@ def login(request, user): # Redirect to oauth login global PREV_PAGE PREV_PAGE = request.META.get('HTTP_REFERER') - redirect_uri = os.path.join('https://dljwql.stsci.edu/authorize') + redirect_uri = f"{get_base_url()}{reverse('jwql:authorize')}" return JWQL_OAUTH.mast_auth.authorize_redirect(request, redirect_uri) From d84c4d5a7f6a3f6b494f6d42b3703980386a95a0 Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Fri, 16 Oct 2020 15:15:59 -0400 Subject: [PATCH 11/12] Upgrade authlib to 0.15.1, now installing with conda --- environment_python_3_6.yml | 3 ++- environment_python_3_7.yml | 3 ++- environment_python_3_8.yml | 3 ++- requirements.txt | 5 +++-- setup.py | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/environment_python_3_6.yml b/environment_python_3_6.yml index 7ce8fd7ca..36d68e578 100644 --- a/environment_python_3_6.yml +++ b/environment_python_3_6.yml @@ -3,6 +3,7 @@ channels: - http://ssb.stsci.edu/astroconda dependencies: - astroquery=0.4 +- authlib=0.15.1 - bokeh>=1.0,<1.4 - django=2.2.5 - drizzle=1.13 @@ -31,9 +32,9 @@ dependencies: - pip: - asdf==2.7.1 - astropy==4.0.1 - - authlib==0.14.3 - codecov==2.1.9 - crds==10.0.0 + - cryptography==3.1.1 - jwedb>=0.0.3 - jwst==0.17.1 - pysqlite3==0.2.2 diff --git a/environment_python_3_7.yml b/environment_python_3_7.yml index 3896ed0b5..377685857 100644 --- a/environment_python_3_7.yml +++ b/environment_python_3_7.yml @@ -3,6 +3,7 @@ channels: - http://ssb.stsci.edu/astroconda dependencies: - astroquery=0.4 +- authlib=0.15.1 - bokeh>=1.0,<1.4 - django=3.0.3 - flake8=3.8.3 @@ -30,9 +31,9 @@ dependencies: - pip: - asdf==2.7.1 - astropy==4.0.1.post1 - - authlib==0.14.3 - codecov==2.1.9 - crds==10.0.0 + - cryptography==3.1.1 - jwedb==0.0.6 - jwst==0.17.1 - pysqlite3==0.4.3 diff --git a/environment_python_3_8.yml b/environment_python_3_8.yml index fae30a4ed..db8bba479 100644 --- a/environment_python_3_8.yml +++ b/environment_python_3_8.yml @@ -2,6 +2,7 @@ channels: - defaults - http://ssb.stsci.edu/astroconda dependencies: +- authlib=0.15.1 - django=3.0.3 - flake8=3.8.3 - inflection=0.3.1 @@ -27,10 +28,10 @@ dependencies: - asdf==2.7.1 - astropy==4.0.1.post1 - astroquery==0.4.1 - - authlib==0.14.3 - bokeh>=1.0,<1.4 - codecov==2.1.9 - crds==10.0.0 + - cryptography==3.1.1 - jwedb==0.0.6 - jwst==0.17.1 - pysiaf==0.9.0 diff --git a/requirements.txt b/requirements.txt index a2b574357..33df6ca07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,11 @@ asdf==2.7.1 astropy==4.0.1.post1 astroquery==0.4.1 -authlib==0.14.3 +authlib==0.15.1 bokeh==1.3.4 codecov==2.1.9 crds==10.0.0 +cryptography==3.1.1 django==2.2.5 flake8==3.8.3 inflection==0.5.1 @@ -12,6 +13,7 @@ ipython==7.18.1 jinja2==2.11.2 jsonschema==3.2.0 jwedb>=0.0.6 +jwst==0.17.1 matplotlib==3.3.2 nodejs==10.13.0 numpy==1.19.2 @@ -26,5 +28,4 @@ sphinx==3.2.1 sqlalchemy==1.3.19 stsci_rtd_theme==0.0.2 twine==3.2.0 -git+https://github.com/spacetelescope/jwst@0.16.2 git+https://github.com/spacetelescope/jwst_reffiles#egg=jwst_reffiles diff --git a/setup.py b/setup.py index 422bebe70..bf87d3b20 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ 'bokeh>=1.0,<1.4', 'codecov', 'crds', + 'cryptography', 'django>=2.0,<3.0', 'flake8', 'inflection', From 1fb079c55ceca5a1a2b3f3ef0f5e8e3a3bf2d48e Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Fri, 16 Oct 2020 16:16:14 -0400 Subject: [PATCH 12/12] Adding @falkben to list of acknowledgements --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9094fad2e..5e54b4f16 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,8 @@ Any questions about the `jwql` project or its software can be directed to `jwql@ - Van Dixon (INS) - Tom Donaldson (DMD) [@tomdonaldson](https://github.com/tomdonaldson) - Kim DuPrie (DMD) -- Jonathan Eisenhamer (DMD) [@stscieisenhamer](https://githublcom/stscieisenhamer) +- Jonathan Eisenhamer (DMD) [@stscieisenhamer](https://github.com/stscieisenhamer) +- Ben Falk (DMD) [@falkben](https://github.com/falkben) - Ann Feild (OPO) - Mike Fox (DSMO) [@mfox22](https://github.com/mfox22) - Scott Friedman (INS)