diff --git a/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html b/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html index 276398521aec9..f79e758110d6b 100644 --- a/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html +++ b/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html @@ -18,8 +18,10 @@ var hash = window.location.hash; accessToken = hash.match(/access_token=([^&]+)/)[1]; idToken = hash.match(/id_token=([^&]+)/)[1]; - $('#accessTokenArea').text(decodeToken(accessToken)); - $('#idTokenArea').text(decodeToken(idToken)); + $('#accessTokenEncodedArea').html(prettyToken(accessToken)); + $('#accessTokenDecodedArea').html(decodeToken(accessToken)); + $('#idTokenEncodedArea').html(prettyToken(idToken)); + $('#idTokenDecodedArea').html(decodeToken(idToken)); }else if(codeInUrl()){ loggedIn === true; $('.implicitLoggedOut').hide(); @@ -34,8 +36,10 @@ accessToken = null; idToken = null; userName = null; - $('#accessTokenArea').text(''); - $('#idTokenArea').text(''); + $('#accessTokenEncodedArea').text(''); + $('#accessTokenDecodedArea').text(''); + $('#idTokenEncodedArea').text(''); + $('#idTokenDecodedArea').text(''); } }); @@ -152,28 +156,47 @@ var tokens = JSON.parse(data); accessToken = tokens.access_token idToken = tokens.id_token - $('#accessTokenArea').text(decodeToken(accessToken)); - $('#idTokenArea').text(decodeToken(idToken)); + $('#accessTokenEncodedArea').html(prettyToken(accessToken)); + $('#accessTokenDecodedArea').html(decodeToken(accessToken)); + $('#idTokenEncodedArea').html(prettyToken(idToken)); + $('#idTokenDecodedArea').html(decodeToken(idToken)); }); } function decodeToken(token) { var parts = token.split("."); if (parts.length == 3) { - var headers = window.atob(parts[0]); - var payload = window.atob(parts[1]); - var jsonPayload = JSON.parse(payload); - if (!userName) { - if (jsonPayload.upn) { - userName = jsonPayload.upn; - } else if (jsonPayload.preferred_username) { - userName = jsonPayload.preferred_username; - } - if (userName) { - $('#userName').append("" + "as " + userName + ""); - } - } - return JSON.stringify(JSON.parse(headers), null, '\t') + "\r\n.\r\n" + JSON.stringify(jsonPayload,null,'\t') + "\r\n.\r\n" + parts[2]; + var headers = window.atob(parts[0]); + var payload = window.atob(parts[1]); + var jsonPayload = JSON.parse(payload); + if (!userName) { + if (jsonPayload.upn) { + userName = jsonPayload.upn; + } else if (jsonPayload.preferred_username) { + userName = jsonPayload.preferred_username; + } + if (userName) { + $('#loggedInUser').append(" Logged in as " + userName); + } + } + return "
" + + JSON.stringify(JSON.parse(headers), null, 4) + + "
" + + JSON.stringify(jsonPayload,null,4) + "" + + parts[2] + ""; + } else { + return token; + } + } + + function prettyToken(token){ + var parts = token.split("."); + if (parts.length == 3) { + var headers = parts[0]; + var payload = parts[1]; + var signature = parts[2]; + + return "" + parts[0] + "." + parts[1] + "." + parts[2] + ""; } else { return token; } @@ -264,42 +287,77 @@ Your tokens -