implemented main part of authorization and token delivery
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -12,7 +12,10 @@
|
||||
<div id="content" style="display: none">
|
||||
<h1>Authorization</h1>
|
||||
Confirmation required: are you shure you want to grant access to <span id="name">some client</span>?
|
||||
<button type="button" onclick="grantAutorization()">Yes</button>
|
||||
<button type="button" onclick="grantAutorization(1)">Yes - 1 day</button>
|
||||
<button type="button" onclick="grantAutorization(7)">Yes - 1 week</button>
|
||||
<button type="button" onclick="grantAutorization(30)">Yes - 1 month</button>
|
||||
<button type="button" onclick="grantAutorization(365)">Yes - 1 year</button>
|
||||
<button type="button" onclick="denyAutorization()">No</button>
|
||||
</div>
|
||||
<div id="error" class="error" style="display: none"></div>
|
||||
|
||||
@@ -24,8 +24,8 @@ async function handleResponse(response){
|
||||
}
|
||||
}
|
||||
|
||||
function grantAutorization(){
|
||||
json.confirmed = true;
|
||||
function grantAutorization(days){
|
||||
json.days = days;
|
||||
backendAutorization();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,25 +15,25 @@
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<td><input type="text" disabled="true" id="client_id" /></td>
|
||||
<td><input type="text" disabled="true" id="client-id" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td><input type="text" id="name" /></td>
|
||||
<td><input type="text" id="client-name" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Secret</th>
|
||||
<td><input type="text" id="secret" /></td>
|
||||
<td><input type="text" id="client-secret" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Redirect URIs</th>
|
||||
<td>
|
||||
<textarea id="redirects"></textarea>
|
||||
<textarea id="redirect-urls"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button type="button" id="button">Update</button></td>
|
||||
<td><button type="button" id="button" onclick="updateClient();">Update</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
@@ -1,20 +1,52 @@
|
||||
var params = new URLSearchParams(window.location.search);
|
||||
var id = params.get('id');
|
||||
|
||||
|
||||
async function handleLoadResponse(response){
|
||||
if (response.ok){
|
||||
var json = await response.json();
|
||||
get('client-id').value = json.client_id;
|
||||
get('client-name').value = json.name;
|
||||
get('client-secret').value = json.secret;
|
||||
get('redirect-urls').value = json.redirect_uris.join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUpdateResponse(response){
|
||||
if (response.ok) {
|
||||
enable('button');
|
||||
setText('button','saved.');
|
||||
}
|
||||
}
|
||||
|
||||
function resetButton(){
|
||||
enable('button');
|
||||
setText('button','Update')
|
||||
}
|
||||
|
||||
function updateClient(){
|
||||
disable('button');
|
||||
setText('button','sent data…')
|
||||
var data = {
|
||||
client_id : getValue('client-id'),
|
||||
name : getValue('client-name'),
|
||||
secret : getValue('client-secret'),
|
||||
redirect_uris : getValue('redirect-urls').split("\n")
|
||||
};
|
||||
fetch(client_controller+'/update',{
|
||||
method : 'POST',
|
||||
headers : {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body : JSON.stringify(data)
|
||||
}).then(handleUpdateResponse);
|
||||
setTimeout(resetButton,4000);
|
||||
}
|
||||
|
||||
fetch(api+'/client',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
client_id : id
|
||||
})
|
||||
}).then(handleResponse);
|
||||
|
||||
async function handleResponse(response){
|
||||
if (response.ok){
|
||||
var json = await response.json();
|
||||
get('client_id').value = json.client_id;
|
||||
get('name').value = json.name;
|
||||
get('secret').value = json.secret;
|
||||
get('redirects').value = json.redirect_uris.join("\n");
|
||||
}
|
||||
}
|
||||
}).then(handleLoadResponse);
|
||||
@@ -4,7 +4,7 @@
|
||||
<title>Light OIDC</title>
|
||||
<script src="common.js"></script>
|
||||
<script src="user.js"></script>
|
||||
<script src="newclient.js"></script>
|
||||
<script src="new_client.js"></script>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
<body>
|
||||
Reference in New Issue
Block a user