Implemented user profile settings, OAuth apps, and maintenance windows. Other minor fixes/improvements

This commit is contained in:
2021-03-11 10:37:07 -05:00
parent a020009c47
commit c58e2fc545
48 changed files with 3152 additions and 36 deletions

57
profile/api/add/add.css Normal file
View File

@ -0,0 +1,57 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#add {
padding: 15px 15px 15px;
}
.lmc-table>tbody:not(.lmc-tbody-head)>tr>td:first-of-type {
font-weight: bold;
text-align: right;
}
#scopes-table {
border-bottom: 1px solid #4C4C4C;
border-collapse: separate;
border-left: 1px solid #B2B2B2;
border-right: 1px solid #4C4C4C;
border-spacing: 2px;
border-top: 1px solid #B2B2B2;
margin-bottom: 30px;
}
#scopes-table label {
display: block;
}
#scopes-table tbody td {
text-align: center;
}
#scopes-table tbody td:first-of-type {
text-align: left;
}
#scopes-table td {
border-bottom: 1px solid #B2B2B2;
border-left: 1px solid #4C4C4C;
border-right: 1px solid #B2B2B2;
border-top: 1px solid #4C4C4C;
padding: 2px;
}

191
profile/api/add/add.js Normal file
View File

@ -0,0 +1,191 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiPost, oauthScopes, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.addButton = "add-button";
elements.expiry = "expiry";
elements.label = "label";
elements.scopeBox = "scope-box";
elements.scopes = "scopes";
elements.selectNone = "select-none";
elements.selectRo = "select-read_only";
elements.selectRw = "select-read_write";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.addButton = {};
ui.expiry = {};
ui.label = {};
ui.scopes = {};
ui.selectNone = {};
ui.selectRo = {};
ui.selectRw = {};
// Display OAuth scopes in scope selector
var displayScopes = function()
{
for (var scope in oauthScopes) {
var row = document.createElement("tr");
var label = document.createElement("td");
label.innerHTML = oauthScopes[scope];
row.appendChild(label);
var none = document.createElement("td");
var noneLabel = document.createElement("label");
noneLabel.htmlFor = "scope-" + scope + "-none";
var noneBox = document.createElement("input");
noneBox.id = "scope-" + scope + "-none";
noneBox.className = elements.scopeBox;
noneBox.type = "radio";
noneBox.name = "scope-" + scope;
noneBox.checked = true;
noneBox.addEventListener("input", handleSelectScope);
noneLabel.appendChild(noneBox);
none.appendChild(noneLabel);
row.appendChild(none);
var ro = document.createElement("td");
var roLabel = document.createElement("label");
roLabel.htmlFor = "scope-" + scope + "-read_only";
var roBox = document.createElement("input");
roBox.id = "scope-" + scope + "-read_only";
roBox.className = elements.scopeBox;
roBox.type = "radio";
roBox.name = "scope-" + scope;
roBox.addEventListener("input", handleSelectScope);
roLabel.appendChild(roBox);
ro.appendChild(roLabel);
row.appendChild(ro);
var rw = document.createElement("td");
var rwLabel = document.createElement("label");
rwLabel.htmlFor = "scope-" + scope + "-read_write";
var rwBox = document.createElement("input");
rwBox.id = "scope-" + scope + "-read_write";
rwBox.className = elements.scopeBox;
rwBox.type = "radio";
rwBox.name = "scope-" + scope;
rwBox.addEventListener("input", handleSelectScope);
rwLabel.appendChild(rwBox);
rw.appendChild(rwLabel);
row.appendChild(rw);
ui.scopes.appendChild(row);
}
};
// Click handler for add button
var handleAdd = function(event)
{
var req = {
"label": ui.label.value
};
var expiry = parseInt(ui.expiry.value);
if (expiry) {
var expireDt = new Date(Date.now() + expiry).toISOString();
req.expiry = expireDt.slice(0, expireDt.indexOf("."));
}
if (ui.selectRw.checked) {
req.scopes = "*";
} else {
req.scopes = [];
var buttons = document.getElementsByClassName(elements.scopeBox);
for (var i = 0; i < buttons.length; i++) {
if (!buttons[i].checked)
continue;
var attrs = buttons[i].id.split("-");
if (attrs[2] == "none")
continue;
req.scopes.push(attrs[1] + ":" + attrs[2]);
}
req.scopes = req.scopes.join(" ");
if (!req.scopes.length) {
alert("You must select some permissions.");
return;
}
}
apiPost("/profile/tokens", req, function(response)
{
alert("Your API token has been created. Store this secret - it won't be shown again.\n" + response.token);
location.href = "/profile/api";
});
};
// Handler for the "select all" row
var handleSelectAll = function(event)
{
var column = event.currentTarget.id.split("-")[1];
var buttons = document.getElementsByClassName(elements.scopeBox);
for (var i = 0; i < buttons.length; i++) {
if (buttons[i].id.split("-")[2] == column)
buttons[i].checked = true;
}
};
// Handler for individual scope selectors
var handleSelectScope = function(event)
{
ui.selectNone.checked = false;
ui.selectRo.checked = false;
ui.selectRw.checked = false;
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.addButton = document.getElementById(elements.addButton);
ui.expiry = document.getElementById(elements.expiry);
ui.label = document.getElementById(elements.label);
ui.scopes = document.getElementById(elements.scopes);
ui.selectNone = document.getElementById(elements.selectNone);
ui.selectRo = document.getElementById(elements.selectRo);
ui.selectRw = document.getElementById(elements.selectRw);
// Add scopes to tables
displayScopes();
ui.selectNone.checked = false;
ui.selectRo.checked = false;
ui.selectRw.checked = false;
// Register event handlers
ui.addButton.addEventListener("click", handleAdd);
ui.selectNone.addEventListener("change", handleSelectAll);
ui.selectRo.addEventListener("change", handleSelectAll);
ui.selectRw.addEventListener("change", handleSelectAll);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

View File

@ -0,0 +1,93 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // Add API Key</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="add.css" />
<script src="add.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="add">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">Add an SSH Key</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Label</td>
<td><input id="label" type="text" size="30" /></td>
</tr>
<tr class="lmc-tr3">
<td>Expires</td>
<td>
<select id="expiry">
<!-- The values are milliseconds, in case you were wondering -->
<option value="0">Never</option>
<option value="3600000">1 hour</option>
<option value="21600000">6 hours</option>
<option value="43200000">12 hours</option>
<option value="86400000">1 day</option>
<option value="172800000">2 days</option>
<option value="604800000">1 week</option>
<option value="1209600000">2 weeks</option>
<option value="2419200000">4 weeks</option>
<option value="15768000000">6 months</option>
<option value="31536000000">12 months</option>
</select>
</td>
</tr>
<tr class="lmc-tr3">
<td>Scopes</td>
<td>
<table id="scopes-table">
<thead>
<tr>
<td>Access</td>
<td>None</td>
<td>Read Only</td>
<td>Read/Write</td>
</tr>
</thead>
<tbody id="scopes">
<tr>
<td><strong>Select All</strong></td>
<td><label for="select-none"><input id="select-none" type="radio" name="select-all" /></label></td>
<td><label for="select-read_only"><input id="select-read_only" type="radio" name="select-all" /></label></td>
<td><label for="select-read_write"><input id="select-read_write" type="radio" name="select-all" /></label></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td><button id="add-button" type="button">Create API Key</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

41
profile/api/api.css Normal file
View File

@ -0,0 +1,41 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#api {
padding: 15px 15px 15px;
}
.app-img {
height: 36px;
vertical-align: middle;
width: 36px;
}
.hover-info {
cursor: help;
text-decoration: dotted underline;
}
td:nth-of-type(5) {
text-align: center;
}
thead span.info {
font-size: 12px;
}

327
profile/api/api.js Normal file
View File

@ -0,0 +1,327 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiDelete, apiGet, apiPut, oauthScopes, parseParams, setupHeader, timeString } from "/global.js";
(function()
{
// Element names specific to this page
elements.apiKeys = "api-keys";
elements.appImg = "app-img";
elements.authorizedApps = "authorized-apps";
elements.hoverInfo = "hover-info";
elements.info = "info";
elements.lmcRow = "lmc-tr1";
elements.lmcRowAlt = "lmc-tr2";
// Data received from API calls
var data = {};
data.apps = [];
data.keys = [];
// Static references to UI elements
var ui = {};
ui.apiKeys = {};
ui.authorizedApps = {};
// Creates a row in the authorized apps table
var createAppRow = function(app, alt)
{
var row = document.createElement("tr");
if (alt)
row.className = elements.lmcRowAlt;
else
row.className = elements.lmcRow;
var thumb = document.createElement("td");
if (app.thumbnail_url && app.thumbnail_url.length) {
var thumbImg = document.createElement("img");
thumbImg.className = elements.appImg;
thumbImg.src = settings.apiURL + app.thumbnail_url;
thumbImg.alt = app.label;
thumb.appendChild(thumbImg);
}
row.appendChild(thumb);
var label = document.createElement("td");
if (app.website && app.website.length) {
var link = document.createElement("a");
link.href = app.website;
link.target = "_blank";
link.innerHTML = app.label;
label.appendChild(link);
} else {
label.innerHTML = app.label;
}
row.appendChild(label);
var created = document.createElement("td");
var created1 = document.createElement("span");
var now = new Date();
var createDt = new Date(app.created + "Z");
created1.innerHTML = timeString(now - createDt, true);
var created2 = document.createElement("span");
created2.className = elements.info;
created2.innerHTML = createDt.toLocaleString();
created.appendChild(created1);
created.appendChild(document.createElement("br"));
created.appendChild(created2);
row.appendChild(created);
var expires = document.createElement("td");
if (app.expiry) {
var expires1 = document.createElement("span");
var expireDt = new Date(app.expiry + "Z");
expires1.innerHTML = timeString(now - expireDt, true);
var expires2 = document.createElement("span");
expires2.className = elements.info;
expires2.innerHTML = expireDt.toLocaleString();
expires.appendChild(expires1);
expires.appendChild(document.createElement("br"));
expires.appendChild(expires2);
} else {
expires.innerHTML = "Never";
}
row.appendChild(expires);
var options = document.createElement("td");
var scopesLink = document.createElement("a");
scopesLink.id = "scopes-app-" + app.id;
scopesLink.href = "#";
scopesLink.innerHTML = "View Scopes";
scopesLink.addEventListener("click", viewScopes);
var separator = document.createElement("span");
separator.innerHTML = " | ";
var removeLink = document.createElement("a");
removeLink.id = "revoke-app-" + app.id;
removeLink.href = "#";
removeLink.innerHTML = "Revoke";
removeLink.addEventListener("click", revoke);
options.appendChild(scopesLink);
options.appendChild(separator);
options.appendChild(removeLink);
row.appendChild(options);
return row;
};
// Creates a row in the API keys table
var createKeyRow = function(key, alt)
{
var row = document.createElement("tr");
if (alt)
row.className = elements.lmcRowAlt;
else
row.className = elements.lmcRow;
var label = document.createElement("td");
label.innerHTML = key.label;
row.appendChild(label);
var prefix = document.createElement("td");
prefix.innerHTML = key.token + "...";
row.appendChild(prefix);
var created = document.createElement("td");
var created1 = document.createElement("span");
var now = new Date();
var createDt = new Date(key.created + "Z");
created1.innerHTML = timeString(now - createDt, true);
var created2 = document.createElement("span");
created2.className = elements.info;
created2.innerHTML = createDt.toLocaleString();
created.appendChild(created1);
created.appendChild(document.createElement("br"));
created.appendChild(created2);
row.appendChild(created);
var expires = document.createElement("td");
if (key.expiry) {
var expires1 = document.createElement("span");
var expireDt = new Date(key.expiry + "Z");
expires1.innerHTML = timeString(now - expireDt, true);
var expires2 = document.createElement("span");
expires2.className = elements.info;
expires2.innerHTML = expireDt.toLocaleString();
expires.appendChild(expires1);
expires.appendChild(document.createElement("br"));
expires.appendChild(expires2);
} else {
expires.innerHTML = "Never";
}
row.appendChild(expires);
var options = document.createElement("td");
var scopesLink = document.createElement("a");
scopesLink.id = "scopes-key-" + key.id;
scopesLink.href = "#";
scopesLink.innerHTML = "View Scopes";
scopesLink.addEventListener("click", viewScopes);
var separator = document.createElement("span");
separator.innerHTML = " | ";
var renameLink = document.createElement("a");
renameLink.id = "rename-" + key.id;
renameLink.href = "#";
renameLink.innerHTML = "Rename";
renameLink.addEventListener("click", handleRename);
var removeLink = document.createElement("a");
removeLink.id = "revoke-key-" + key.id;
removeLink.href = "#";
removeLink.innerHTML = "Revoke";
removeLink.addEventListener("click", revoke);
options.appendChild(scopesLink);
options.appendChild(separator);
options.appendChild(renameLink);
options.appendChild(separator.cloneNode(true));
options.appendChild(removeLink);
row.appendChild(options);
return row;
};
// Callback for authorized apps API call
var displayApps = function(response)
{
data.apps = data.apps.concat(response.data);
// Request the next page if there are more
if (response.page != response.pages) {
apiGet("/profile/apps?page=" + (response.page + 1), displayApps, null);
return;
}
// Add apps to table
for (var i = 0; i < data.apps.length; i++)
ui.authorizedApps.appendChild(createAppRow(data.apps[i], i % 2));
};
// Callback for ssh keys API call
var displayKeys = function(response)
{
data.keys = data.keys.concat(response.data);
// Request the next page if there are more
if (response.page != response.pages) {
apiGet("/profile/tokens?page=" + (response.page + 1), displayKeys, null);
return;
}
// Add keys to table
for (var i = 0; i < data.keys.length; i++)
ui.apiKeys.appendChild(createKeyRow(data.keys[i], i % 2));
};
// Handler for renaming an API token
var handleRename = function(event)
{
var id = event.currentTarget.id.split("-")[1];
var name = prompt("Rename API token:");
if (!name)
return;
var req = {
"label": name
};
apiPut("/profile/tokens/" + id, req, function(response)
{
location.reload();
});
};
// Revokes an API key or app
var revoke = function(event)
{
var info = event.currentTarget.id.split("-");
var isApp = (info[1] == "app");
var id = parseInt(info[2]);
var message = "Are you sure you want to remove this API key?";
var url = "/profile/tokens/";
if (isApp) {
message = "Are you sure you want to revoke access for this app?";
url = "/profile/apps/";
}
if (!confirm(message))
return;
apiDelete(url + id, function(response)
{
location.reload();
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.apiKeys = document.getElementById(elements.apiKeys);
ui.authorizedApps = document.getElementById(elements.authorizedApps);
// Get data from API
apiGet("/profile/tokens", displayKeys, null);
apiGet("/profile/apps", displayApps, null);
};
// Display the scopes for a given app or key
var viewScopes = function(event)
{
var info = event.currentTarget.id.split("-");
var isApp = (info[1] == "app");
var id = parseInt(info[2]);
var searchArr = data.keys;
if (isApp)
searchArr = data.apps;
var scopeStr = "";
for (var i = 0; i < searchArr.length; i++) {
if (searchArr[i].id == id) {
scopeStr = searchArr[i].scopes;
break;
}
}
var scopes = [];
if (scopeStr == "*") {
for (var scope in oauthScopes)
scopes.push(scope + ":read_write");
} else {
scopes = scopeStr.split(" ");
}
var alertStr = "";
for (var i = 0; i < scopes.length; i++) {
var scopeInfo = scopes[i].split(":");
alertStr += oauthScopes[scopeInfo[0]] + " - ";
if (scopeInfo[1] == "read_write")
alertStr += "Read/Write\n";
else
alertStr += "Read Only\n";
}
alert(alertStr);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

67
profile/api/index.shtml Normal file
View File

@ -0,0 +1,67 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // API Keys</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="api.css" />
<script src="api.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="api">
<table class="lmc-table">
<thead>
<tr>
<td colspan="5">API Keys</td>
</tr>
<tr>
<td>Label</td>
<td>Key <span class="info">(prefix only)</span></td>
<td>Created</td>
<td>Expires</td>
<td>Options</td>
</tr>
</thead>
<tbody id="api-keys"></tbody>
</table>
<p class="sub-links">
<a href="/profile/api/add">Add an API Key</a>
</p>
<table class="lmc-table">
<thead>
<tr>
<td colspan="5">Authorized Apps</td>
</tr>
<tr>
<td></td>
<td>App</td>
<td>Created</td>
<td>Expires</td>
<td>Options</td>
</tr>
</thead>
<tbody id="authorized-apps"></tbody>
</table>
</div>
</div>
</body>
</html>

31
profile/auth/auth.css Normal file
View File

@ -0,0 +1,31 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#auth {
padding: 15px 15px 15px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}
.tfa {
display: none;
}

164
profile/auth/auth.js Normal file
View File

@ -0,0 +1,164 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiDelete, apiGet, apiPost, parseParams, setupHeader, timeString } from "/global.js";
(function()
{
// Element names specific to this page
elements.pwReset = "pw-reset";
elements.tfa = "tfa";
elements.tfaDisable = "tfa-disable";
elements.tfaEnable = "tfa-enable";
elements.tfaStatus = "tfa-status";
elements.trusted = "trusted";
elements.untrust = "untrust";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.pwReset = {};
ui.tfa = [];
ui.tfaDisable = {};
ui.tfaEnable = {};
ui.tfaStatus = {};
ui.trusted = {};
// Creates a row for the trusted devices list
var createTrustedRow = function(device)
{
var row = document.createElement("div");
row.id = elements.trusted + "-" + device.id;
var br = document.createElement("br");
row.appendChild(br);
var userAgent = document.createElement("span");
userAgent.innerHTML = device.user_agent;
row.appendChild(userAgent);
row.appendChild(br.cloneNode(true));
var lastAuth = document.createElement("span");
var now = new Date();
var authDt = new Date(device.last_authenticated + "Z");
lastAuth.innerHTML = "Last authenticated " + timeString(now - authDt, true) + " from " + device.last_remote_addr;
row.appendChild(lastAuth);
row.appendChild(br.cloneNode(true));
var expiry = document.createElement("span");
var expireDt = new Date(device.expiry + "Z");
expiry.innerHTML = "Expires in " + timeString(expireDt - now, false) + " - ";
row.appendChild(expiry);
var untrust = document.createElement("a");
untrust.id = elements.untrust + "-" + device.id;
untrust.href = "#";
untrust.innerHTML = "untrust";
untrust.addEventListener("click", handleUntrust);
row.appendChild(untrust);
return row;
};
// Callback for profile API call
var displayProfile = function(response)
{
ui.pwReset.href += response.username;
if (response.two_factor_auth) {
apiGet("/profile/devices", displayTrusted, null);
ui.tfaStatus.innerHTML = "Enabled";
ui.tfaEnable.innerHTML = "Reset Two-Factor Authentication";
for (var i = 0; i < ui.tfa.length; i++) {
if (ui.tfa[i].tagName == "TR")
ui.tfa[i].style.display = "table-row";
else
ui.tfa[i].style.display = "initial";
}
} else {
ui.tfaStatus.innerHTML = "Disabled";
}
ui.tfaEnable.disabled = false;
};
// Callback for trusted devices API call
var displayTrusted = function(response)
{
for (var i = 0; i < response.data.length; i++)
ui.trusted.appendChild(createTrustedRow(response.data[i]));
};
// Click handler for disable 2FA link
var handleDisableTFA = function(event)
{
if (!confirm("Are you sure you want to disable two-factor authentication?"))
return;
apiPost("/profile/tfa-disable", {}, function(response)
{
location.reload();
});
};
// Click handler for enable/reset 2FA button
var handleEnableTFA = function(event)
{
if (event.currentTarget.disabled)
return;
location.href = "/profile/twofactor";
};
// Click handler for untrust links
var handleUntrust = function(event)
{
var deviceID = parseInt(event.currentTarget.id.split("-")[1]);
apiDelete("/profile/devices/" + deviceID, function(response)
{
var row = document.getElementById(elements.trusted + "-" + deviceID);
row.remove();
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.pwReset = document.getElementById(elements.pwReset);
ui.tfa = document.getElementsByClassName(elements.tfa);
ui.tfaDisable = document.getElementById(elements.tfaDisable);
ui.tfaEnable = document.getElementById(elements.tfaEnable);
ui.tfaStatus = document.getElementById(elements.tfaStatus);
ui.trusted = document.getElementById(elements.trusted);
// Register event handlers
ui.tfaDisable.addEventListener("click", handleDisableTFA);
ui.tfaEnable.addEventListener("click", handleEnableTFA);
// Get data from API
apiGet("/profile", displayProfile, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

80
profile/auth/index.shtml Normal file
View File

@ -0,0 +1,80 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // Password & Authentication</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="auth.css" />
<script src="auth.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="auth">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">Authentication</td>
</tr>
<tr>
<td colspan="2">Change Password</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Reset Password</td>
<td><a id="pw-reset" href="https://login.linode.com/forgot/password?username=" target="_blank">Click here to reset your password</a></td>
</tr>
</tbody>
<tbody class="lmc-tbody-head">
<tr class="noshow">
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2">Two-Factor Authentication</td>
</tr>
</tbody>
<tbody>
<tr class="lmc-tr3">
<td>Description</td>
<td>When two-factor authentication is enabled, you'll need to provide a token before you can log in to your Linode account.</td>
</tr>
<tr class="lmc-tr3">
<td>Status</td>
<td>Two-factor authentication is currently: <strong><span id="tfa-status"></span></strong><span class="tfa"> - <a id="tfa-disable" href="#">disable</a></span></td>
</tr>
<tr class="lmc-tr3 tfa">
<td>Scratch Code</td>
<td>One-time use emergency scratch code is shown only once.</td>
</tr>
<tr class="lmc-tr3 tfa">
<td>Trusted Computers</td>
<td id="trusted">The following computers can skip two-factor authentication:</td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td><button disabled id="tfa-enable" type="button">Enable Two-Factor Authentication</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

93
profile/index.shtml Normal file
View File

@ -0,0 +1,93 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="profile.css" />
<script src="profile.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="profile">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">My Profile (<span id="user"></span>, in case you forgot)</td>
</tr>
<tr>
<td colspan="2">Timezone</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Timezone</td>
<td>
LMC automatically detects your timezone from your system.<br />
Your current timezone offset is: <strong><span id="timezone"></span></strong>
</td>
</tr>
</tbody>
<tbody class="lmc-tbody-head">
<tr class="noshow">
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2">Email</td>
</tr>
</tbody>
<tbody>
<tr class="lmc-tr3">
<td>Current Email</td>
<td id="current-address"></td>
</tr>
<tr class="lmc-tr3">
<td>New Email</td>
<td><input id="new-address" type="email" size="30" /></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td><button id="change-button" type="button">Change Email</button></td>
</tr>
</tbody>
<tbody class="lmc-tbody-head">
<tr class="noshow">
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2">Linode Events Email</td>
</tr>
</tbody>
<tbody>
<tr class="lmc-tr3">
<td>Events Email Notification</td>
<td>Notifications are currently: <span id="notifications"></span></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td><button disabled id="toggle-notifications" type="button">Toggle Event Email Notifications</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

87
profile/lish/index.shtml Normal file
View File

@ -0,0 +1,87 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // Lish Settings</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="lish.css" />
<script src="lish.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="lish">
<p id="settings-saved">Settings saved.</p>
<table class="lmc-table">
<thead>
<tr>
<td colspan="3">Lish Authentication</td>
</tr>
<tr>
<td colspan="3">Authentication Methods</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Authentication modes</td>
<td>
<select id="modes">
<option value="password_keys">Allow both password and key authentication</option>
<option value="keys_only">Allow key authentication only</option>
<option value="disabled">Disable Lish</option>
</select>
</td>
<td class="info">
This controls what authentication methods are allowed to connect to the<br />
Lish console servers. <a target="_blank" href="https://www.linode.com/docs/platform/manager/using-the-linode-shell-lish/">About the Lish console...</a>
</td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td colspan="2"><button disabled id="save-button" type="button">Save Setting</button></td>
</tr>
</tbody>
<tbody class="lmc-tbody-head">
<tr class="noshow">
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3">Lish Keys</td>
</tr>
</tbody>
<tbody>
<tr class="lmc-tr3">
<td>Description</td>
<td colspan="2">Place your SSH public keys here for use with Lish console access.</td>
</tr>
<tr class="lmc-tr3">
<td>Lish Keys</td>
<td colspan="2"><textarea id="keys" cols="80" rows="2" wrap="soft"></textarea></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td colspan="2"><button disabled id="submit-button" type="button">Submit Keys</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

39
profile/lish/lish.css Normal file
View File

@ -0,0 +1,39 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#lish {
padding: 15px 15px 15px;
}
#keys {
white-space: pre;
}
#settings-saved {
background-color: #ADD370;
display: none;
font-size: 16px;
margin-top: 0;
padding: 7px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}

115
profile/lish/lish.js Normal file
View File

@ -0,0 +1,115 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiGet, apiPut, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.keys = "keys";
elements.modes = "modes";
elements.saveButton = "save-button";
elements.settingsSaved = "settings-saved";
elements.submitButton = "submit-button";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.keys = {};
ui.modes = {};
ui.saveButton = {};
ui.settingsSaved = {};
ui.submitButton = {};
// Callback for profile API call
var displayProfile = function(response)
{
// Populate auth method settings
ui.modes.value = response.lish_auth_method;
ui.saveButton.disabled = false;
// Populate authorized keys
ui.keys.value = response.authorized_keys.join("\n");
ui.submitButton.disabled = false;
};
// Click handler for save button
var handleSave = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"lish_auth_method": ui.modes.value
};
apiPut("/profile", req, function(response)
{
ui.settingsSaved.style.display = "block";
});
};
// Click handler for submit button
var handleSubmit = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"authorized_keys": ui.keys.value.split("\n")
};
// Remove empty keys from the request
for (var i = req.authorized_keys.length - 1; i >= 0; i--) {
if (!req.authorized_keys[i].length)
req.authorized_keys.splice(i, 1);
}
apiPut("/profile", req, function(response)
{
ui.settingsSaved.style.display = "block";
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.keys = document.getElementById(elements.keys);
ui.modes = document.getElementById(elements.modes);
ui.saveButton = document.getElementById(elements.saveButton);
ui.settingsSaved = document.getElementById(elements.settingsSaved);
ui.submitButton = document.getElementById(elements.submitButton);
// Register event handlers
ui.saveButton.addEventListener("click", handleSave);
ui.submitButton.addEventListener("click", handleSubmit);
// Get data from API
apiGet("/profile", displayProfile, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

31
profile/profile.css Normal file
View File

@ -0,0 +1,31 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#notifications {
font-weight: bold;
}
#profile {
padding: 15px 15px 15px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}

127
profile/profile.js Normal file
View File

@ -0,0 +1,127 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiGet, apiPut, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.changeButton = "change-button";
elements.currentAddress = "current-address";
elements.newAddress = "new-address";
elements.notifications = "notifications";
elements.timezone = "timezone";
elements.toggleNotifications = "toggle-notifications";
elements.user = "user";
// Data received from API calls
var data = {};
data.profile = {};
// Static references to UI elements
var ui = {};
ui.changeButton = {};
ui.currentAddress = {};
ui.newAddress = {};
ui.notifications = {};
ui.timezone = {};
ui.toggleNotifications = {};
ui.user = {};
// Callback for profile API call
var displayProfile = function(response)
{
data.profile = response;
ui.user.innerHTML = data.profile.username;
ui.currentAddress.innerHTML = data.profile.email;
if (data.profile.email_notifications)
ui.notifications.innerHTML = "Enabled";
else
ui.notifications.innerHTML = "Disabled";
ui.toggleNotifications.disabled = false;
};
// Event handler for change email button
var handleChange = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"email": ui.newAddress.value
};
apiPut("/profile", req, function(response)
{
ui.newAddress.value = "";
location.reload();
});
};
// Click handler for toggle notifications button
var handleToggle = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"email_notifications": !data.profile.email_notifications
};
apiPut("/profile", req, function(response)
{
location.reload();
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.changeButton = document.getElementById(elements.changeButton);
ui.currentAddress = document.getElementById(elements.currentAddress);
ui.newAddress = document.getElementById(elements.newAddress);
ui.notifications = document.getElementById(elements.notifications);
ui.timezone = document.getElementById(elements.timezone);
ui.toggleNotifications = document.getElementById(elements.toggleNotifications);
ui.user = document.getElementById(elements.user);
// Display timezone info
var now = new Date();
var offset = now.getTimezoneOffset() / -60;
ui.timezone.innerHTML = "GMT";
if (offset >= 0)
ui.timezone.innerHTML += "+";
ui.timezone.innerHTML += offset;
// Register event handlers
ui.changeButton.addEventListener("click", handleChange);
ui.toggleNotifications.addEventListener("click", handleToggle);
// Get data from API
apiGet("/profile", displayProfile, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

View File

@ -0,0 +1,62 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // Referrals</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="referrals.css" />
<script src="referrals.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="referrals">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">Referrals</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Description</td>
<td>
Referrals reward you when you refer people to Linode. If someone signs up using your referral code, you'll receive a credit of<br />
$20.00, so long as the person you referred remains an active customer for 90 days.
</td>
</tr>
<tr class="lmc-tr3">
<td>Your referral code</td>
<td id="code"></td>
</tr>
<tr class="lmc-tr3">
<td>Your referral URL</td>
<td id="url"></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td>You have <span id="total"></span> total referrals: <span id="completed"></span> completed ($<span id="dollars"></span>) and <span id="pending"></span> pending</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,35 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#code {
font-family: monospace;
}
#referrals {
padding: 15px 15px 15px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}
#url {
font-family: monospace;
}

View File

@ -0,0 +1,75 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiGet, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.code = "code";
elements.completed = "completed";
elements.dollars = "dollars";
elements.pending = "pending";
elements.total = "total";
elements.url = "url";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.code = {};
ui.completed = {};
ui.dollars = {};
ui.pending = {};
ui.total = {};
ui.url = {};
// Callback for profile API call
var displayProfile = function(response)
{
ui.code.innerHTML = response.referrals.code;
ui.url.innerHTML = response.referrals.url;
ui.total.innerHTML = response.referrals.total;
ui.completed.innerHTML = response.referrals.completed;
ui.dollars.innerHTML = response.referrals.credit.toFixed(2);
ui.pending.innerHTML = response.referrals.pending;
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.code = document.getElementById(elements.code);
ui.completed = document.getElementById(elements.completed);
ui.dollars = document.getElementById(elements.dollars);
ui.pending = document.getElementById(elements.pending);
ui.total = document.getElementById(elements.total);
ui.url = document.getElementById(elements.url);
// Get data from API
apiGet("/profile", displayProfile, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

27
profile/ssh/add/add.css Normal file
View File

@ -0,0 +1,27 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#add {
padding: 15px 15px 15px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}

69
profile/ssh/add/add.js Normal file
View File

@ -0,0 +1,69 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiPost, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.addButton = "add-button";
elements.key = "key";
elements.label = "label";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.addButton = {};
ui.key = {};
ui.label = {};
// Click handler for add button
var handleAdd = function(event)
{
var req = {
"label": ui.label.value,
"ssh_key": ui.key.value
};
apiPost("/profile/sshkeys", req, function(response)
{
location.href = "/profile/ssh";
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.addButton = document.getElementById(elements.addButton);
ui.key = document.getElementById(elements.key);
ui.label = document.getElementById(elements.label);
// Register event handlers
ui.addButton.addEventListener("click", handleAdd);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

View File

@ -0,0 +1,55 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // Add SSH Key</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="add.css" />
<script src="add.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="add">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">Add an SSH Key</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Label</td>
<td><input id="label" type="text" size="50" /></td>
</tr>
<tr class="lmc-tr3">
<td>SSH Public Key</td>
<td><textarea id="key" cols="58" rows="10"></textarea></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td><button id="add-button" type="button">Add SSH Key</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

51
profile/ssh/index.shtml Normal file
View File

@ -0,0 +1,51 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // SSH Keys</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="ssh.css" />
<script src="ssh.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="ssh">
<table class="lmc-table">
<thead>
<tr>
<td colspan="4">SSH Keys</td>
</tr>
<tr>
<td>Label</td>
<td>Key</td>
<td>Created</td>
<td>Options</td>
</tr>
</thead>
<tbody id="ssh-keys"></tbody>
</table>
<p class="sub-links">
<a href="/profile/ssh/add">Add an SSH Key</a>
</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - My Profile // Remove SSH Key</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="remove.css" />
<script src="remove.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="remove">
<p>Are you sure you want to delete the key <strong id="label"></strong>?</p>
<button disabled id="remove-button" type="button">Yes, delete this sucker</button>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,22 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
#remove {
padding: 15px 15px 15px;
}

View File

@ -0,0 +1,80 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiDelete, apiGet, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.label = "label";
elements.removeButton = "remove-button";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.label = {};
ui.removeButton = {};
// Callback for key API call
var displayKey = function(response)
{
ui.label.innerHTML = response.label;
ui.removeButton.disabled = false;
};
// Click handler for remove button
var handleRemove = function(event)
{
if (event.currentTarget.disabled)
return;
apiDelete("/profile/sshkeys/" + data.params.kid, function(response)
{
location.href = "/profile/ssh";
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
// We need a key ID, so die if we don't have it
if (!data.params.kid) {
alert("No key ID supplied!");
return;
}
setupHeader();
// Get element references
ui.label = document.getElementById(elements.label);
ui.removeButton = document.getElementById(elements.removeButton);
// Register event handlers
ui.removeButton.addEventListener("click", handleRemove);
// Get data from API
apiGet("/profile/sshkeys/" + data.params.kid, displayKey, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

31
profile/ssh/ssh.css Normal file
View File

@ -0,0 +1,31 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
.hover-info {
cursor: help;
text-decoration: dotted underline;
}
#ssh {
padding: 15px 15px 15px;
}
td:nth-of-type(4) {
text-align: right;
}

120
profile/ssh/ssh.js Normal file
View File

@ -0,0 +1,120 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiGet, md5, parseParams, setupHeader, timeString } from "/global.js";
(function()
{
// Element names specific to this page
elements.hoverInfo = "hover-info";
elements.lmcRow = "lmc-tr1";
elements.lmcRowAlt = "lmc-tr2";
elements.sshKeys = "ssh-keys";
// Data received from API calls
var data = {};
data.keys = [];
// Static references to UI elements
var ui = {};
ui.sshKeys = {};
// Creates a row in the SSH keys table
var createKeyRow = function(key, alt)
{
var row = document.createElement("tr");
if (alt)
row.className = elements.lmcRowAlt;
else
row.className = elements.lmcRow;
var label = document.createElement("td");
label.innerHTML = key.label;
row.appendChild(label);
var keyInfo = document.createElement("td");
var start = document.createElement("span");
start.className = elements.hoverInfo;
start.title = key.ssh_key;
start.innerHTML = key.ssh_key.substring(0, 26);
keyInfo.appendChild(start);
var br = document.createElement("br");
keyInfo.appendChild(br);
var fingerprint = document.createElement("span");
try {
fingerprint.innerHTML = "Fingerprint: " + md5(atob(key.ssh_key.split(" ")[1]), true);
} catch (error) {
fingerprint.innerHTML = "Invalid key";
}
keyInfo.appendChild(fingerprint);
row.appendChild(keyInfo);
var created = document.createElement("td");
var now = new Date();
var createDate = new Date(key.created + "Z");
created.innerHTML = timeString(now - createDate, true);
row.appendChild(created);
var options = document.createElement("td");
var removeLink = document.createElement("a");
removeLink.href = "/profile/ssh/remove?kid=" + key.id;
removeLink.innerHTML = "Remove";
options.appendChild(removeLink);
row.appendChild(options);
return row;
};
// Callback for ssh keys API call
var displayKeys = function(response)
{
data.keys = data.keys.concat(response.data);
// Request the next page if there are more
if (response.page != response.pages) {
apiGet("/profile/sshkeys?page=" + (response.page + 1), displayKeys, null);
return;
}
// Redirect to add page if there are no keys
if (!data.keys.length)
location.href = "/profile/ssh/add";
// Add keys to table
for (var i = 0; i < data.keys.length; i++)
ui.sshKeys.appendChild(createKeyRow(data.keys[i], i % 2));
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.sshKeys = document.getElementById(elements.sshKeys);
// Get data from API
apiGet("/profile/sshkeys", displayKeys, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

View File

@ -0,0 +1,98 @@
<!--
This file is part of Linode Manager Classic.
Linode Manager Classic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Linode Manager Classic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LMC - Two-Factor Authentication</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="twofactor.css" />
<script src="twofactor.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/profile_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="top-links"><a href="/profile">My Profile</a> » <a href="/profile/auth">Password & Authentication</a> » <span class="top-links-title">Enable Two-Factor Authentication</span></div>
<div id="twofactor">
<table class="lmc-table">
<thead>
<tr>
<td colspan="3">Enable Two-Factor Authentication</td>
</tr>
<tr>
<td colspan="3">Step 1</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Dscription</td>
<td colspan="2">Scan the QR code (or enter the key) into your two-factor application.</td>
</tr>
<tr class="lmc-tr3">
<td>Secret Key</td>
<td id="tfa-secret"></td>
<td class="info">Save this key in a safe place, it will only be shown once.</td>
</tr>
<tr class="lmc-tr3">
<td>QR Code</td>
<td id="qr-code"><img id="qr-code-img" src="//:0" alt="qr-code" /></td>
<td></td>
</tr>
</tbody>
<tbody class="lmc-tbody-head">
<tr class="noshow">
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3">Step 2</td>
</tr>
</tbody>
<tbody>
<tr class="lmc-tr3">
<td>Description</td>
<td colspan="2">Use your two-factor app to generate a token to verify everything is working correctly.</td>
</tr>
<tr class="lmc-tr3">
<td>Generated Token</td>
<td colspan="2"><input id="tfa-token" type="text" size="30" /></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td colspan="2"><button disabled id="confirm-button" type="button">Confirm my token, and enable two-factor auth!</button></td>
</tr>
</tbody>
<tbody class="lmc-tbody-head">
<tr>
<td colspan="3">Recovery Procedure</td>
</tr>
</tbody>
</table>
<div id="recovery-procedure">
If you lose your token and get locked out of your account, email <a href="mailto:support@linode.com">support@linode.com</a> to regain access to your account.<br />
<br />
Should you need Linode to disable your Two-Factor Authentication, the following information is required:<br />
<ol>
<li>An image of the front and back of the payment card on file, which clearly shows both the last 6 digits and owner of the card</li>
<li>An image of the front and back of the matching government-issued photo ID</li>
</ol>
</div>
<div id="more-info" class="info">Read Linode's <a target="_blank" href="https://www.linode.com/docs/security/authentication/two-factor-authentication/linode-manager-security-controls/">two-factor authentication</a> documentation for more information.</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,52 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
@import url('/global.css');
.lmc-table:first-of-type tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}
#more-info {
font-size: 12px;
margin-top: 20px;
text-align: center;
}
#qr-code {
padding: 32px;
}
#qr-code-img {
display: inline-block;
height: 136px;
width: 136px;
}
#recovery-procedure {
font-size: 13.3px;
padding: 5px;
}
#tfa-secret {
font-family: monospace;
}
#twofactor {
padding: 15px 15px 15px;
}

View File

@ -0,0 +1,95 @@
/*
* This file is part of Linode Manager Classic.
*
* Linode Manager Classic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Linode Manager Classic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
*/
import { settings, elements, apiPost, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.confirmButton = "confirm-button";
elements.qrCode = "qr-code-img";
elements.subnav = "subnav-link";
elements.subnavActive = "subnav-link-active";
elements.tfaSecret = "tfa-secret";
elements.tfaToken = "tfa-token";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.confirmButton = {};
ui.qrCode = {};
ui.tfaSecret = {};
ui.tfaToken = {};
// Callback for TFA API call
var displaySecret = function(response)
{
ui.tfaSecret.innerHTML = response.secret;
ui.confirmButton.disabled = false;
};
// Click handler for confirm button
var handleConfirm = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"tfa_code": ui.tfaToken.value
};
apiPost("/profile/tfa-enable-confirm", req, function(response) {
alert("Your emergency scratch code is: " + response.scratch + "\nRecord this code and store it in a safe place. You will not be able to view it again!");
location.href = "/profile/auth";
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Highlight the auth subnav link
var subnavLinks = document.getElementsByClassName(elements.subnav);
for (var i = 0; i < subnavLinks.length; i++) {
if (subnavLinks[i].pathname == "/profile/auth")
subnavLinks[i].className = elements.subnav + " " + elements.subnavActive;
else
subnavLinks[i].className = elements.subnav;
}
// Get element references
ui.confirmButton = document.getElementById(elements.confirmButton);
ui.qrCode = document.getElementById(elements.qrCode);
ui.tfaSecret = document.getElementById(elements.tfaSecret);
ui.tfaToken = document.getElementById(elements.tfaToken);
// Register event handlers
ui.confirmButton.addEventListener("click", handleConfirm);
// Get data from API
apiPost("/profile/tfa-enable", {}, displaySecret);
};
// Attach onload handler
window.addEventListener("load", setup);
})();