Add auth-managed proxy UI improvements
This commit is contained in:
@ -11,8 +11,11 @@
|
||||
background-image: url("/static/pub/long-banner.jpg");
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
min-height: 50px;
|
||||
}
|
||||
img.banner {
|
||||
height: 50px;
|
||||
@ -24,6 +27,15 @@
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
.allow-from-options {
|
||||
display: flex;
|
||||
gap: 0.35rem;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 0.35rem;
|
||||
}
|
||||
.allow-from-options .button {
|
||||
height: 1.8rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@ -34,6 +46,15 @@
|
||||
</div>
|
||||
<div class="banner-container">
|
||||
<!-- <img class="banner-long" src="/static/pub/long-banner.jpg"/> -->
|
||||
<div class="navbar-end pr-4">
|
||||
<div class="navbar-item">
|
||||
<span class="has-text-white mr-3">Signed in as {{.Username}}</span>
|
||||
<a class="button is-small is-warning mr-2" href="/users">{{if eq .Role "admin"}}Users{{else}}Account{{end}}</a>
|
||||
<form method="post" action="/logout" autocomplete="off">
|
||||
<button class="button is-small is-light" type="submit">Logout</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@ -49,6 +70,7 @@
|
||||
<th>Dest Host/IP</th>
|
||||
<th>Expiration</th>
|
||||
<th>Status</th>
|
||||
<th>Created By</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -64,11 +86,15 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<input class="input is-link is-small" type="text" form="add-noodle" name="src" list="allow-from-options" placeholder="All or source IP" value="All" autocomplete="off" required/>
|
||||
<input class="input is-link is-small" type="text" form="add-noodle" name="src" list="allow-from-options" placeholder="All, comma-separated IPs, or CIDRs" value="All" autocomplete="off" required/>
|
||||
<datalist id="allow-from-options">
|
||||
<option value="All"></option>
|
||||
<option value="{{.ClientIP}}"></option>
|
||||
</datalist>
|
||||
<div class="allow-from-options">
|
||||
<button class="button is-small is-white" type="button" onclick="setAllowFromValue('All')">All</button>
|
||||
<button class="button is-small is-white" type="button" onclick="setAllowFromValue('{{.ClientIP}}')">{{.ClientIP}}</button>
|
||||
</div>
|
||||
</td>
|
||||
<td><input class="input is-link is-small" type="text" form="add-noodle" name="listen_port" placeholder="Listen Port" autocomplete="off" required/></td>
|
||||
<td><input class="input is-link is-small" type="text" form="add-noodle" name="dest_port" placeholder="Destination Port" autocomplete="off" required/></td>
|
||||
@ -76,6 +102,8 @@
|
||||
<td><input class="input is-link is-small" type="text" form="add-noodle" name="expiration" placeholder="30m, 1h15m" autocomplete="off" required/></td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<form id="add-noodle" method="post" action="/add" autocomplete="off">
|
||||
<button class="button" type="submit">
|
||||
@ -101,10 +129,14 @@
|
||||
</label>
|
||||
</form>
|
||||
</td>
|
||||
<td>{{.CreatedBy}}</td>
|
||||
<td>
|
||||
<a href="/delete?id={{.Id}}">
|
||||
<span class="icon has-text-danger"><i class="fas fa-minus"></i></span>
|
||||
</a>
|
||||
<form method="post" action="/delete" autocomplete="off" onsubmit="return confirm('Delete this proxy?');">
|
||||
<input type="hidden" name="id" value="{{.Id}}"/>
|
||||
<button class="button is-white" type="submit" aria-label="Delete noodle">
|
||||
<span class="icon has-text-danger"><i class="fas fa-minus"></i></span>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
@ -114,11 +146,20 @@
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<strong>Infinite-Noodles Network Proxy</strong> - © 2025 Jimmy Allen
|
||||
<strong>Infinite-Noodles Network Proxy</strong>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script>
|
||||
function setAllowFromValue(value) {
|
||||
const input = document.querySelector('input[name="src"]');
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
input.value = value;
|
||||
input.focus();
|
||||
}
|
||||
|
||||
function formatDuration(ms) {
|
||||
if (ms <= 0) {
|
||||
return "0s";
|
||||
|
||||
101
internal/assets/templates/login.html
Normal file
101
internal/assets/templates/login.html
Normal file
@ -0,0 +1,101 @@
|
||||
<!DOCTYPE html>
|
||||
<html data-theme="dark">
|
||||
<head>
|
||||
<title>Infinite-Noodles Login</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/static/pub/bulma.min.css">
|
||||
<link rel="stylesheet" href="/static/pub/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
min-height: 100vh;
|
||||
background-color: #000;
|
||||
color: #f5f5f5;
|
||||
}
|
||||
.banner-container {
|
||||
background-image: url("/static/pub/long-banner.jpg");
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
min-height: 50px;
|
||||
}
|
||||
img.banner {
|
||||
height: 50px;
|
||||
}
|
||||
.login-shell {
|
||||
min-height: calc(100vh - 52px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 440px;
|
||||
background: #111;
|
||||
border-radius: 18px;
|
||||
border: 1px solid #2f2f2f;
|
||||
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
|
||||
overflow: hidden;
|
||||
}
|
||||
.login-body {
|
||||
padding: 2rem;
|
||||
}
|
||||
.login-body .label,
|
||||
.login-body .help,
|
||||
.login-body p,
|
||||
.login-body strong {
|
||||
color: #f5f5f5;
|
||||
}
|
||||
.login-body .input {
|
||||
background: #1b1b1b;
|
||||
border-color: #3d3d3d;
|
||||
color: #f5f5f5;
|
||||
}
|
||||
.login-body .input::placeholder {
|
||||
color: #9a9a9a;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar is-fixed-top" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<img class="banner" src="/static/pub/logo.jpg"/>
|
||||
</div>
|
||||
<div class="banner-container"></div>
|
||||
</nav>
|
||||
<main class="login-shell">
|
||||
<section class="login-card">
|
||||
<div class="login-body">
|
||||
{{if .Error}}
|
||||
<article class="message is-danger">
|
||||
<div class="message-body">{{.Error}}</div>
|
||||
</article>
|
||||
{{end}}
|
||||
<form method="post" action="/login" autocomplete="off">
|
||||
<div class="field">
|
||||
<label class="label">Username</label>
|
||||
<div class="control has-icons-left">
|
||||
<input class="input" type="text" name="username" required autofocus>
|
||||
<span class="icon is-small is-left"><i class="fas fa-user"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Password</label>
|
||||
<div class="control has-icons-left">
|
||||
<input class="input" type="password" name="password" required>
|
||||
<span class="icon is-small is-left"><i class="fas fa-lock"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<button class="button is-link is-fullwidth" type="submit">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
234
internal/assets/templates/users.html
Normal file
234
internal/assets/templates/users.html
Normal file
@ -0,0 +1,234 @@
|
||||
<!DOCTYPE html>
|
||||
<html data-theme="dark">
|
||||
<head>
|
||||
<title>User Configuration</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/static/pub/bulma.min.css">
|
||||
<link rel="stylesheet" href="/static/pub/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
min-height: 100vh;
|
||||
background-color: #000;
|
||||
color: #f5f5f5;
|
||||
}
|
||||
.banner-container {
|
||||
background-image: url("/static/pub/long-banner.jpg");
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
min-height: 50px;
|
||||
}
|
||||
img.banner {
|
||||
height: 50px;
|
||||
}
|
||||
.page-shell {
|
||||
padding: 5rem 1.25rem 3rem;
|
||||
}
|
||||
.page-card {
|
||||
background: #111;
|
||||
border-radius: 18px;
|
||||
border: 1px solid #2f2f2f;
|
||||
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
.title,
|
||||
.subtitle,
|
||||
.label,
|
||||
.table,
|
||||
.table th,
|
||||
.table td,
|
||||
strong,
|
||||
p {
|
||||
color: #f5f5f5;
|
||||
}
|
||||
.table {
|
||||
background: transparent;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.table th,
|
||||
.table td {
|
||||
border-color: #2f2f2f;
|
||||
vertical-align: top;
|
||||
padding: 0.5rem 0.6rem;
|
||||
}
|
||||
.input,
|
||||
.select select {
|
||||
background: #1b1b1b;
|
||||
border-color: #3d3d3d;
|
||||
color: #f5f5f5;
|
||||
}
|
||||
.input::placeholder {
|
||||
color: #9a9a9a;
|
||||
}
|
||||
.user-actions .button,
|
||||
.user-actions .input,
|
||||
.user-actions .select select {
|
||||
font-size: 0.8rem;
|
||||
height: 2rem;
|
||||
}
|
||||
.user-actions .field:not(:last-child) {
|
||||
margin-bottom: 0.4rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar is-fixed-top" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<img class="banner" src="/static/pub/logo.jpg"/>
|
||||
</div>
|
||||
<div class="banner-container"></div>
|
||||
</nav>
|
||||
<section class="page-shell">
|
||||
<div class="container is-max-desktop">
|
||||
<div class="level mb-5">
|
||||
<div class="level-left">
|
||||
<div>
|
||||
<h1 class="title is-3">User Configuration</h1>
|
||||
<p class="subtitle is-6">Signed in as {{.Username}} ({{.Role}})</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="buttons">
|
||||
<a class="button is-light" href="/">Back to Proxies</a>
|
||||
<form method="post" action="/logout" autocomplete="off">
|
||||
<button class="button is-dark" type="submit">Logout</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if .Error}}
|
||||
<article class="message is-danger">
|
||||
<div class="message-body">{{.Error}}</div>
|
||||
</article>
|
||||
{{end}}
|
||||
|
||||
<div class="columns is-variable is-5">
|
||||
<div class="column is-5">
|
||||
{{if ne .Role "admin"}}
|
||||
<div class="box page-card">
|
||||
<h2 class="title is-5">Change Your Password</h2>
|
||||
<form method="post" action="/users/password" autocomplete="off">
|
||||
<input type="hidden" name="username" value="{{.Username}}">
|
||||
<div class="field">
|
||||
<label class="label">New Password</label>
|
||||
<div class="control">
|
||||
<input class="input" type="password" name="password" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Confirm Password</label>
|
||||
<div class="control">
|
||||
<input class="input" type="password" name="confirm_password" required>
|
||||
</div>
|
||||
</div>
|
||||
<button class="button is-link is-fullwidth" type="submit">Update Password</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if eq .Role "admin"}}
|
||||
<div class="box page-card">
|
||||
<h2 class="title is-5">Add User</h2>
|
||||
<form method="post" action="/users/add" autocomplete="off">
|
||||
<div class="field">
|
||||
<label class="label">Username</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" name="username" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Password</label>
|
||||
<div class="control">
|
||||
<input class="input" type="password" name="password" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Role</label>
|
||||
<div class="control">
|
||||
<div class="select is-fullwidth">
|
||||
<select name="role">
|
||||
<option value="regular">regular</option>
|
||||
<option value="admin">admin</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="button is-link is-fullwidth" type="submit">Create User</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="column">
|
||||
{{if eq .Role "admin"}}
|
||||
<div class="box page-card">
|
||||
<h2 class="title is-5">Existing Users</h2>
|
||||
<table class="table is-fullwidth is-striped is-hoverable is-narrow">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Role</th>
|
||||
<th>Created</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Users}}
|
||||
<tr>
|
||||
<td>{{.Username}}</td>
|
||||
<td>{{.Role}}</td>
|
||||
<td>{{.CreatedAt.Format "2006-01-02 15:04:05 UTC"}}</td>
|
||||
<td class="user-actions">
|
||||
<form method="post" action="/users/role" autocomplete="off" class="mb-2">
|
||||
<input type="hidden" name="username" value="{{.Username}}">
|
||||
<div class="field has-addons">
|
||||
<div class="control is-expanded">
|
||||
<div class="select is-small is-fullwidth">
|
||||
<select name="role">
|
||||
<option value="regular" {{if eq .Role "regular"}}selected{{end}}>regular</option>
|
||||
<option value="admin" {{if eq .Role "admin"}}selected{{end}}>admin</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-small is-info" type="submit">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form method="post" action="/users/password" autocomplete="off" class="mb-2">
|
||||
<input type="hidden" name="username" value="{{.Username}}">
|
||||
<div class="field has-addons">
|
||||
<div class="control is-expanded">
|
||||
<input class="input is-small" type="password" name="password" placeholder="New password" required>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-small is-warning" type="submit">Set Password</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form method="post" action="/users/delete" autocomplete="off" onsubmit="return confirm('Delete user {{.Username}}?');">
|
||||
<input type="hidden" name="username" value="{{.Username}}">
|
||||
<button class="button is-small is-danger is-light" type="submit">Delete User</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="box page-card">
|
||||
<h2 class="title is-5">Account</h2>
|
||||
<p class="mb-2"><strong>Username:</strong> {{.Username}}</p>
|
||||
<p><strong>Role:</strong> {{.Role}}</p>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user