handle JWT token
This commit is contained in:
parent
ccdae5708f
commit
89c346f512
3 changed files with 28 additions and 14 deletions
|
@ -13,7 +13,7 @@ body {
|
|||
display: block;
|
||||
color: #586e75;
|
||||
margin: 2em auto 0;
|
||||
max-width: 30em;
|
||||
max-width: 45em;
|
||||
font-family: Consolas, Menlo, monospace;
|
||||
line-height: 1.2em;
|
||||
font-size: 18px;
|
||||
|
@ -50,6 +50,7 @@ pre { padding: 1em;
|
|||
.button:hover {
|
||||
cursor: pointer;
|
||||
color: #FFF;
|
||||
background-color: #268bd2;
|
||||
box-shadow: 4px 4px 0 #000;
|
||||
border-color: #000; }
|
||||
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>Yolo App</h1>
|
||||
<a href="http://localhost:9001/iroh/oauth2/authorize?response_type=code&client_id=localtest&redirect_uri=http%3A%2F%2Flocalhost%3A9999%2Flogin.html&scope=ctia&state=yolo" target="_blank">
|
||||
click Here to authorize me with the <code>ctia</code> scope!
|
||||
</a>
|
||||
<a class="button" href="http://localhost:9001/iroh/oauth2/authorize?response_type=code&client_id=localtest&redirect_uri=http%3A%2F%2Flocalhost%3A9999%2Flogin.html&scope=ctia%20iroh-collect&state=yolo" target="_blank">
|
||||
click Here
|
||||
</a> to authorize me with the scopes:
|
||||
<ul><li> <code>ctia</code></li>
|
||||
<li><code>iroh-collect</code></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
30
login.html
30
login.html
|
@ -7,20 +7,30 @@
|
|||
<body>
|
||||
<script>
|
||||
function getJsonFromUrl() {
|
||||
var query = location.search.substr(1);
|
||||
var result = {};
|
||||
query.split("&").forEach(function(part) {
|
||||
var item = part.split("=");
|
||||
result[item[0]] = decodeURIComponent(item[1]);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
var params=getJsonFromUrl()
|
||||
var query = location.search.substr(1);
|
||||
var result = {};
|
||||
query.split("&").forEach(function(part) {
|
||||
var item = part.split("=");
|
||||
result[item[0]] = decodeURIComponent(item[1]);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
var params=getJsonFromUrl();
|
||||
function jwtDecode(t) {
|
||||
let token = {};
|
||||
token.raw = t;
|
||||
token.header = JSON.parse(window.atob(t.split('.')[0]));
|
||||
token.payload = JSON.parse(window.atob(t.split('.')[1]));
|
||||
return (token)
|
||||
}
|
||||
var jwt=jwtDecode(params.code).payload;
|
||||
</script>
|
||||
<h1>Yolo App login page</h1>
|
||||
<p>Authorization process done!</p>
|
||||
<a href="/index.html">← go back to main page</a>
|
||||
<p>the returned code is:</p>
|
||||
<p>the returned jwt is:</p>
|
||||
<pre class="code"><script>document.write(JSON.stringify(jwt,null,2));</script></pre>
|
||||
<p>decoded from the code:</p>
|
||||
<pre class="code"><script>document.write(params.code);</script></pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue