Count9 #7

Merged
tygozwolle merged 20 commits from count9 into master 2026-08-03 12:17:13 +02:00
2 changed files with 24 additions and 24 deletions
Showing only changes of commit 87d6d7e764 - Show all commits
@@ -87,20 +87,19 @@ public class AccountEnforcementService : BackgroundService
// Disable the account
profile.Status = "Expired";
// Remove Cleartext-Password from radcheck so FreeRADIUS rejects future auth
var checks = await db.RadCheck
.Where(rc => rc.Username == profile.Username)
.ToListAsync(ct);
db.RadCheck.RemoveRange(checks);
// Insert Auth-Type := Reject to explicitly deny
db.RadCheck.Add(new RadCheck
// Scramble the password so the device prompts for new credentials
var check = await db.RadCheck.FirstOrDefaultAsync(rc => rc.Username == profile.Username && rc.Attribute == "Cleartext-Password", ct);
if (check != null)
{
Username = profile.Username,
Attribute = "Auth-Type",
Op = ":=",
Value = "Reject"
});
check.Value = "REJECT_" + Guid.NewGuid().ToString("N").Substring(0, 8);
}
// Cleanup any old Auth-Type Reject entries
var rejectCheck = await db.RadCheck.FirstOrDefaultAsync(rc => rc.Username == profile.Username && rc.Attribute == "Auth-Type", ct);
if (rejectCheck != null)
{
db.RadCheck.Remove(rejectCheck);
}
_logger.LogInformation("Account '{Username}' disabled. Reason: {Reason}", profile.Username, reason);
+12 -11
View File
@@ -272,17 +272,18 @@ public class RadiusService : IRadiusService
profile.Status = "Revoked";
// Remove Cleartext-Password and insert Auth-Type := Reject
var checks = await _db.RadCheck.Where(rc => rc.Username == profile.Username).ToListAsync();
_db.RadCheck.RemoveRange(checks);
_db.RadCheck.Add(new RadCheck
// Scramble the password instead of Auth-Type := Reject so devices prompt for new credentials
var check = await _db.RadCheck.FirstOrDefaultAsync(rc => rc.Username == profile.Username && rc.Attribute == "Cleartext-Password");
if (check != null)
{
Username = profile.Username,
Attribute = "Auth-Type",
Op = ":=",
Value = "Reject"
});
check.Value = "REJECT_" + Guid.NewGuid().ToString("N").Substring(0, 8);
}
var rejectCheck = await _db.RadCheck.FirstOrDefaultAsync(rc => rc.Username == profile.Username && rc.Attribute == "Auth-Type");
if (rejectCheck != null)
{
_db.RadCheck.Remove(rejectCheck);
}
await _db.SaveChangesAsync();
@@ -331,7 +332,7 @@ public class RadiusService : IRadiusService
});
}
if (profile.Status == "Revoked")
if (profile.Status == "Revoked" || profile.Status == "Expired")
{
profile.Status = "Active";
var rejectCheck = await _db.RadCheck.FirstOrDefaultAsync(rc => rc.Username == profile.Username && rc.Attribute == "Auth-Type");