Skip to content

Commit

Permalink
Rearrange functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dangra committed Sep 18, 2018
1 parent 03eaa0e commit f16d18a
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions sso/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ def sso_login():
return _redirect_to_google_auth(payload)


def _redirect_to_google_auth(payload):
state = jwt.encode(payload, settings.DISCOURSE_SECRET, 'HS256')
query = urllib.parse.urlencode({
'client_id': settings.GOOGLE_CLIENT_ID,
'redirect_uri': settings.GOOGLE_REDIRECT_URI,
'response_type': 'token',
'scope': 'profile email',
'hd': settings.GOOGLE_DOMAIN,
'state': state,
})
url = '{}?{}'.format(settings.GOOGLE_AUTH_URL, query)
return redirect(url)


@app.route('/discourse/sso/google-oauth2/callback')
def google_oauth2_callback():
return render_template('google-oauth2-callback.html')
Expand Down Expand Up @@ -93,3 +79,15 @@ def _sign_payload(payload, secret=settings.DISCOURSE_SECRET):
).hexdigest()


def _redirect_to_google_auth(payload):
state = jwt.encode(payload, settings.DISCOURSE_SECRET, 'HS256')
query = urllib.parse.urlencode({
'client_id': settings.GOOGLE_CLIENT_ID,
'redirect_uri': settings.GOOGLE_REDIRECT_URI,
'response_type': 'token',
'scope': 'profile email',
'hd': settings.GOOGLE_DOMAIN,
'state': state,
})
url = '{}?{}'.format(settings.GOOGLE_AUTH_URL, query)
return redirect(url)

0 comments on commit f16d18a

Please sign in to comment.