10abd36340
Authentication previously implied full authorization: any valid token could manage every host, DNS provider, domain, and user. This adds SSO login and a per-domain rights model. OIDC login (authorization_code + PKCE): - conf.oidc + conf.auth blocks; clientSecret in (gitignored) secrets.js. - utils/oidc.js (state/PKCE, code exchange, userinfo) using global fetch. - models/oidc_state.js: short-lived state store, auto-expiring via model-redis 1.5 per-key TTL. - routes/auth.js: GET /auth/oidc/start + /auth/oidc/callback; JIT-provisions a local user, mints an AuthToken carrying the SSO groups, hands the token to the browser via a URL fragment. "Log in with SSO" button on the login page. Authorization (groups + app overrides, per-domain, with ownership): - models/grant.js + utils/roles.js (pure, unit-tested): effective rights from conf.auth (admin users/groups, group->role map), Grant records (user|group -> global|domain -> viewer|manager|admin), and ownership (created_by). Roles rank admin > manager(owner) > viewer. - AuthToken stores session groups; middleware/auth.js exposes req.groups. - middleware/authz.js: requireAdmin, requireDomainRole(minRole, resolveDomain), filterViewable. Applied across routes: host mutations need manager on the host's domain; reads are filtered to visible domains; DNS providers, user management, and grant management are global-admin-only; certs need viewer. - routes/grant.js: admin CRUD for grants. Anti-lockout via conf.auth.adminUsers plus migrations/grant_bootstrap.js. Frontend: /me returns effective rights; nav gates Users/Grants to admins; grants management page; OIDC token-fragment handling in app-base.js. Tests: utils/roles and utils/oidc unit-tested (no redis); wired into the test scripts. Full suite 89 pass. Also verified end-to-end against redis (grant resolution, middleware allow/deny/403, list filtering) and the OIDC pure flow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
109 lines
4.4 KiB
Plaintext
Executable File
109 lines
4.4 KiB
Plaintext
Executable File
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
<title>Proxy - Theta 42 <%- title %></title>
|
|
<!-- Favicon -->
|
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
|
<!-- CSS are placed here -->
|
|
<link rel="stylesheet" href="/static-modules/bootstrap/dist/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="/static-modules/@fortawesome/fontawesome-free/css/all.min.css">
|
|
|
|
<link rel='stylesheet' href='/static/css/styles.css' />
|
|
<!-- Scripts are placed here -->
|
|
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
|
|
<script type="text/javascript" src='/static-modules/jquery/dist/jquery.js'></script>
|
|
<!-- <script type="text/javascript" src="/static/lib/js/popper-1.16.0.min.js"></script> -->
|
|
<!-- <script type="text/javascript" src="/static-modules/bootstrap/dist/js/bootstrap.min.js"></script> -->
|
|
<script type="text/javascript" src="/static-modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script type="text/javascript" src="/static-modules/@fortawesome/fontawesome-free/js/all.min.js"></script>
|
|
<script type="text/javascript" src='/static-modules/mustache/mustache.min.js'></script>
|
|
<script type="text/javascript" src='/static-modules/jq-repeat/dist/js/jq-repeat.js'></script>
|
|
<script type="text/javascript" src='/static/lib/js/val.js'></script>
|
|
<script type="text/javascript" src="/static-modules/moment/moment.js"></script>
|
|
<script type="text/javascript" src="/static/lib/js/app-base.js"></script>
|
|
<script type="text/javascript" src="/static/js/app.js"></script>
|
|
|
|
|
|
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
|
<!--[if lt IE 9]>
|
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
|
<a class="navbar-brand" href="#">Dynamic Proxy <%- titleIcon %></a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
|
|
<ul class="navbar-nav top-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="/hosts">
|
|
<i class="fa-solid fa-network-wired"></i>
|
|
Hosts
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/dns"><i class="fa-solid fa-record-vinyl"></i>
|
|
DNS
|
|
</a>
|
|
</li>
|
|
<li class="nav-item nav-admin" style="display: none;">
|
|
<a class="nav-link" href="/users"><i class="fa-solid fa-users"></i>
|
|
Users
|
|
</a>
|
|
</li>
|
|
<li class="nav-item nav-admin" style="display: none;">
|
|
<a class="nav-link" href="/grants"><i class="fa-solid fa-user-shield"></i>
|
|
Grants
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="https://github.com/theta42/proxy" target="_blank">
|
|
<i class="fa-brands fa-github"></i>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
<div class="form-inline mt-2 mt-md-0">
|
|
<a id="cl-login-button" class="btn btn-outline-danger my-2 my-sm-0" onclick="app.auth.forceLogin()" style="display: none;">
|
|
<i class="fas fa-sign-out"></i>
|
|
Login
|
|
</a>
|
|
|
|
<button id="cl-logout-button" class="btn btn-outline-danger my-2 my-sm-0" onclick="app.auth.logOut(e => window.location.href='/')" style="display: none;">
|
|
<i class="fas fa-sign-out"></i>
|
|
Log Out
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
|
|
// Set the correct link to active in the top nav bar
|
|
$('.top-nav a').each(function(index){
|
|
let $this = $(this);
|
|
$this.removeClass('active');
|
|
if($this.attr('href').toLocaleLowerCase() === window.location.pathname.toLocaleLowerCase()){
|
|
$this.addClass('active')
|
|
}
|
|
})
|
|
|
|
// Set the correct login/logout button, and reveal admin-only nav
|
|
// items for global admins.
|
|
app.auth.isLoggedIn(function(error, data){
|
|
if(data) $('#cl-logout-button').show();
|
|
else $('#cl-login-button').show();
|
|
|
|
if(data && data.isAdmin) $('.nav-admin').css('display', '');
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
<!-- Container -->
|
|
<div id="spa-shell" class="container-fluid"> |