Skip to content

Commit

Permalink
Merge pull request #895 from uc-cdis/fix/parsae_urls
Browse files Browse the repository at this point in the history
Fix Parse URL for RAS
  • Loading branch information
BinamB committed Apr 8, 2021
2 parents d6fe2b2 + f723eaa commit 256c724
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fence/blueprints/login/ras.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import jwt
import os
from flask_sqlalchemy_session import current_session
import urllib.request, urllib.parse, urllib.error
import urllib.request, urllib.error
from urllib.parse import urlparse, parse_qs

from fence.models import GA4GHVisaV1, IdentityProvider

Expand Down Expand Up @@ -75,9 +76,10 @@ def post_login(self, user=None, token_result=None):
expires = config["RAS_REFRESH_EXPIRATION"]

# User definied RAS refresh token expiration time
parsed_url = urllib.parse.parse_qs(flask.session.get("redirect"))
if parsed_url.get("upstream_expires_in"):
custom_refresh_expiration = parsed_url.get("upstream_expires_in")[0]
parsed_url = urlparse(flask.session.get("redirect"))
query_params = parse_qs(parsed_url.query)
if query_params.get("upstream_expires_in"):
custom_refresh_expiration = query_params.get("upstream_expires_in")[0]
expires = get_valid_expiration(
custom_refresh_expiration,
expires,
Expand Down

0 comments on commit 256c724

Please sign in to comment.