easier to configure version
This commit is contained in:
parent
1c3827a88b
commit
0f15c8f4a6
3 changed files with 44 additions and 18 deletions
37
index.html
37
index.html
|
@ -2,6 +2,18 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Authorize an App</title>
|
<title>Authorize an App</title>
|
||||||
<link rel="stylesheet" href="brutalist.css" />
|
<link rel="stylesheet" href="brutalist.css" />
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
|
<script src="./infos.js"></script>
|
||||||
|
<script>
|
||||||
|
var displayAuthUrl=oauthServerUrl + "?\n\t"
|
||||||
|
+ "response_type=" + encodeURIComponent(response_type) + "\n\t"
|
||||||
|
+ "&client_id=" + encodeURIComponent(client_id) + "\n\t"
|
||||||
|
+ "&redirect_uri=" + encodeURIComponent(redirect_uri) + "\n\t"
|
||||||
|
+ "&scope=" + encodeURIComponent(scope) + "\n\t"
|
||||||
|
+ "&state=" + encodeURIComponent(state);
|
||||||
|
|
||||||
|
var authUrl=displayAuthUrl.replace("\n","");
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>OAuth2 Client Demo App</h1>
|
<h1>OAuth2 Client Demo App</h1>
|
||||||
|
@ -9,19 +21,20 @@
|
||||||
<p>The only thing needed to ask an user to grants the Yolo app
|
<p>The only thing needed to ask an user to grants the Yolo app
|
||||||
access to Visibility is just putting a simple link:</p>
|
access to Visibility is just putting a simple link:</p>
|
||||||
<p>Here the button is a link to:</p>
|
<p>Here the button is a link to:</p>
|
||||||
<pre>http://localhost:9001/iroh/oauth2/authorize?
|
<pre id="displayUrlPre"></pre>
|
||||||
response_type=code
|
|
||||||
&client_id=localtest
|
|
||||||
&redirect_uri=http%3A%2F%2Flocalhost%3A9999%2Flogin.html
|
|
||||||
&scope=ctia%20ui-settings
|
|
||||||
&state=whatever</pre>
|
|
||||||
|
|
||||||
<a class="button"
|
<a id="authURLLink" href="#">click Here</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%20ui-settings&state=whatever"
|
to authorize me with the <strong>scopes</strong>:
|
||||||
>click Here</a> to authorize me with the scopes:
|
|
||||||
|
|
||||||
<ul><li><code>ctia</code></li>
|
<ul id="scopes"></ul>
|
||||||
<li><code>ui-settings</code></li>
|
<script>
|
||||||
</ul>
|
$.when( $.ready ).then(function () {
|
||||||
|
$("#displayUrlPre").html(displayAuthUrl);
|
||||||
|
$("#authURLLink").attr("href",displayAuthUrl);
|
||||||
|
$.each(scopes,function(i,scope){
|
||||||
|
$("#scopes").append("<li>"+scope+"</li>\n");
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
16
infos.js
Normal file
16
infos.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
var oauthServerUrl="http://localhost:9001/iroh/oauth2/authorize";
|
||||||
|
var response_type="code";
|
||||||
|
var client_id="localtest";
|
||||||
|
var client_password = "localpass";
|
||||||
|
var redirect_uri="http://localhost:9999/login.html";
|
||||||
|
var scopes=["casebook"
|
||||||
|
,"collect"
|
||||||
|
,"ctia"
|
||||||
|
,"enrich"
|
||||||
|
,"inspect"
|
||||||
|
,"integration"
|
||||||
|
,"iroh-auth"
|
||||||
|
,"response"
|
||||||
|
,"ui-settings"];
|
||||||
|
var scope=scopes.join(" ");
|
||||||
|
var state="whatever";
|
|
@ -4,6 +4,7 @@
|
||||||
<title>OAuth2 Demo Login</title>
|
<title>OAuth2 Demo Login</title>
|
||||||
<link rel="stylesheet" href="brutalist.css" />
|
<link rel="stylesheet" href="brutalist.css" />
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
|
<script src="./infos.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
|
@ -64,10 +65,6 @@
|
||||||
<pre id="refreshed-access-token" class="code">Nothing yet.</pre>
|
<pre id="refreshed-access-token" class="code">Nothing yet.</pre>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
/* Client conf */
|
|
||||||
var client_id = "localtest";
|
|
||||||
var client_password = "localpass";
|
|
||||||
var req_scope="ctia iroh-collect";
|
|
||||||
/* ----- */
|
/* ----- */
|
||||||
function getJsonFromUrl() {
|
function getJsonFromUrl() {
|
||||||
var query = location.search.substr(1);
|
var query = location.search.substr(1);
|
||||||
|
@ -117,7 +114,7 @@
|
||||||
var tokparams={
|
var tokparams={
|
||||||
"code":params.code
|
"code":params.code
|
||||||
, "redirect_uri":"http://localhost:9999/login.html"
|
, "redirect_uri":"http://localhost:9999/login.html"
|
||||||
, "scope":req_scope
|
, "scope":scope
|
||||||
, "client_id":client_id
|
, "client_id":client_id
|
||||||
, "grant_type":"authorization_code"
|
, "grant_type":"authorization_code"
|
||||||
};
|
};
|
||||||
|
@ -148,7 +145,7 @@
|
||||||
var getAccessToken = function() {
|
var getAccessToken = function() {
|
||||||
var tokparams={
|
var tokparams={
|
||||||
"refresh_token":refreshToken
|
"refresh_token":refreshToken
|
||||||
, "scope":req_scope
|
, "scope":scope
|
||||||
, "client_id":client_id
|
, "client_id":client_id
|
||||||
, "grant_type":"refresh_token"
|
, "grant_type":"refresh_token"
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue