listo funcionmiento por usuario y contraseña
This commit is contained in:
@@ -99,6 +99,46 @@ app.post('/accounting', (req, res) => {
|
||||
return res.status(200).json({});
|
||||
});
|
||||
|
||||
// Authorize inner-tunnel (EAP): devolver Cleartext-Password para el usuario
|
||||
app.post('/authorize-inner', (req, res) => {
|
||||
console.log('--- RADIUS Authorize (inner) ---');
|
||||
console.log(JSON.stringify(req.body, null, 2));
|
||||
|
||||
const attrs = normalizeAttributes(req.body);
|
||||
const users = {
|
||||
'user1': 'contra1',
|
||||
'user2': 'contra2',
|
||||
};
|
||||
const username = (attrs['User-Name'] || '').toString();
|
||||
const password = users[username];
|
||||
|
||||
if (!password) {
|
||||
pushRequest({
|
||||
id: Date.now() + ':' + Math.random().toString(16).slice(2),
|
||||
ts: new Date().toISOString(),
|
||||
type: 'authorize-inner',
|
||||
attrs,
|
||||
decision: 'notfound',
|
||||
});
|
||||
// No devolvemos nada -> FreeRADIUS seguirá su flujo y probablemente rechace
|
||||
return res.status(200).json({});
|
||||
}
|
||||
|
||||
pushRequest({
|
||||
id: Date.now() + ':' + Math.random().toString(16).slice(2),
|
||||
ts: new Date().toISOString(),
|
||||
type: 'authorize-inner',
|
||||
attrs,
|
||||
decision: 'provide-password',
|
||||
});
|
||||
|
||||
return res.status(200).json({
|
||||
control: {
|
||||
'Cleartext-Password': password,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// API: recent requests
|
||||
app.get('/api/requests', (req, res) => {
|
||||
res.json({ items: requests.slice(-MAX_REQUESTS) });
|
||||
|
||||
@@ -58,16 +58,17 @@ let history = [];
|
||||
|
||||
function renderItem(ev) {
|
||||
const div = document.createElement('div');
|
||||
const isAuth = ev.type === 'authorize';
|
||||
const isAuth = ev.type === 'authorize' || ev.type === 'authorize-inner';
|
||||
div.className = 'item ' + (isAuth ? 'type-auth' : 'type-acct');
|
||||
const user = ev.attrs?.['User-Name'] || ev.attrs?.['User-Name*0'] || '-';
|
||||
const nas = ev.attrs?.['NAS-IP-Address'] || '-';
|
||||
const calling = ev.attrs?.['Calling-Station-Id'] || '-';
|
||||
const called = ev.attrs?.['Called-Station-Id'] || '-';
|
||||
const kind = ev.type === 'authorize-inner' ? 'EAP Inner' : (isAuth ? 'Authorize' : 'Accounting');
|
||||
div.innerHTML = `
|
||||
<div><strong>${isAuth ? 'Authorize' : 'Accounting'}</strong> • <small>${new Date(ev.ts).toLocaleString()}</small></div>
|
||||
<div><strong>${kind}</strong> • <small>${new Date(ev.ts).toLocaleString()}</small></div>
|
||||
<div>Usuario: <code>${user}</code> • NAS: <code>${nas}</code> • STA: <code>${calling}</code> • AP: <code>${called}</code></div>
|
||||
${isAuth ? `<div>Decisión: <strong>${ev.decision}</strong> • VLAN: <code>${ev.vlan}</code> • BW: <code>${(ev.bandwidth?.down/1e6)||10}↓ / ${(ev.bandwidth?.up/1e6)||10}↑ Mbps</code></div>` : ''}
|
||||
${isAuth ? `<div>Decisión: <strong>${ev.decision||'-'}</strong>${ev.vlan?` • VLAN: <code>${ev.vlan}</code>`:''}${ev.bandwidth?` • BW: <code>${(ev.bandwidth?.down/1e6)||10}↓ / ${(ev.bandwidth?.up/1e6)||10}↑ Mbps</code>`:''}</div>` : ''}
|
||||
<div class="attrs">${JSON.escape ? JSON.escape(JSON.stringify(ev.attrs, null, 2)) : JSON.stringify(ev.attrs, null, 2)}</div>
|
||||
`;
|
||||
list.appendChild(div);
|
||||
|
||||
Reference in New Issue
Block a user