-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<html> | ||
<h1>Redirecting...</h1> | ||
<script> | ||
// config vars, TODO move to something more configurable | ||
var redirect_uri = "https://YOUR_APP/callback" | ||
var audience = "wolf.cci.emory.edu/camic_uat" | ||
var scope = "openid%20email" | ||
var client_id = "YLRDUmEs5Jivi6FX3XtNNAt97X3a0epD" | ||
var response_type = "id_token" | ||
var base_auth_url = "https://birmstuff.auth0.com/authorize?" | ||
var cookie_name = "token" // "token" is expected by elevate router | ||
// make the url | ||
var auth_url = base_auth_url | ||
auth_url += "&audience=" + audience | ||
auth_url += "&scope=" + scope | ||
auth_url += "&response_type=" + response_type | ||
auth_url += "&client_id=" + client_id | ||
auth_url += "&redirect_uri=" + redirect_uri | ||
|
||
function getUrlParam(name, url) { | ||
if (!url) url = window.location.href; | ||
name = name.replace(/[\[\]]/g, '\\$&'); | ||
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), | ||
results = regex.exec(url); | ||
if (!results) return null; | ||
if (!results[2]) return ''; | ||
return decodeURIComponent(results[2].replace(/\+/g, ' ')); | ||
} | ||
|
||
// get variables | ||
let id_token = getUrlParam("id_token") | ||
let state = getUrlParam("state") | ||
// is this a login pre or post? | ||
if (id_token){ | ||
document.cookie = cookie_name +"=" + id_token; | ||
window.location = state | ||
} else { | ||
auth_url += "&state=" + state | ||
window.location = auth_url | ||
} | ||
</script> | ||
<html> |