feat: add toggleable audit log functionality based on server environment variable
Release / release (pull_request) Successful in 22s
Release / release (pull_request) Successful in 22s
This commit is contained in:
@@ -883,7 +883,13 @@ def _connect_with_jump_chain(host_id: int) -> tuple[paramiko.SSHClient, paramiko
|
|||||||
raise RuntimeError("failed to build jump chain")
|
raise RuntimeError("failed to build jump chain")
|
||||||
|
|
||||||
|
|
||||||
|
def is_audit_log_enabled() -> bool:
|
||||||
|
return os.getenv("ENABLE_AUDIT_LOG", "true").lower() in ("1", "true", "yes")
|
||||||
|
|
||||||
|
|
||||||
def _insert_connection_audit(host_row: dict[str, Any]) -> int | None:
|
def _insert_connection_audit(host_row: dict[str, Any]) -> int | None:
|
||||||
|
if not is_audit_log_enabled():
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
with db_cursor() as (_, cur):
|
with db_cursor() as (_, cur):
|
||||||
cur.execute(
|
cur.execute(
|
||||||
@@ -964,9 +970,10 @@ def api_logout():
|
|||||||
@app.route("/api/me", methods=["GET"])
|
@app.route("/api/me", methods=["GET"])
|
||||||
def api_me():
|
def api_me():
|
||||||
version = app.config.get("VERSION", "unknown")
|
version = app.config.get("VERSION", "unknown")
|
||||||
|
audit_enabled = is_audit_log_enabled()
|
||||||
if session.get("logged_in"):
|
if session.get("logged_in"):
|
||||||
return jsonify({"logged_in": True, "app_version": version})
|
return jsonify({"logged_in": True, "app_version": version, "audit_log_enabled": audit_enabled})
|
||||||
return jsonify({"logged_in": False, "app_version": version})
|
return jsonify({"logged_in": False, "app_version": version, "audit_log_enabled": audit_enabled})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/identities", methods=["GET"])
|
@app.route("/api/identities", methods=["GET"])
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ interface TabItem {
|
|||||||
const loggedIn = ref(false);
|
const loggedIn = ref(false);
|
||||||
const checking = ref(true);
|
const checking = ref(true);
|
||||||
const appVersion = ref("unknown");
|
const appVersion = ref("unknown");
|
||||||
|
const auditLogEnabled = ref(true);
|
||||||
const identities = ref<IdentityRow[]>([]);
|
const identities = ref<IdentityRow[]>([]);
|
||||||
const allHosts = ref<HostRow[]>([]);
|
const allHosts = ref<HostRow[]>([]);
|
||||||
const allFolders = ref<FolderRow[]>([]);
|
const allFolders = ref<FolderRow[]>([]);
|
||||||
@@ -347,6 +348,9 @@ onMounted(async () => {
|
|||||||
if (m.app_version) {
|
if (m.app_version) {
|
||||||
appVersion.value = m.app_version;
|
appVersion.value = m.app_version;
|
||||||
}
|
}
|
||||||
|
if (m.audit_log_enabled !== undefined) {
|
||||||
|
auditLogEnabled.value = m.audit_log_enabled;
|
||||||
|
}
|
||||||
if (loggedIn.value) await refreshData();
|
if (loggedIn.value) await refreshData();
|
||||||
} catch {
|
} catch {
|
||||||
loggedIn.value = false;
|
loggedIn.value = false;
|
||||||
@@ -918,6 +922,7 @@ async function deleteIdentityRow(id: number) {
|
|||||||
API keys
|
API keys
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
v-if="auditLogEnabled"
|
||||||
type="button"
|
type="button"
|
||||||
class="hidden rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white md:inline-flex"
|
class="hidden rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white md:inline-flex"
|
||||||
@click="openAuditLog"
|
@click="openAuditLog"
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ function browseParams(folderId: number | null, q: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const api = {
|
export const api = {
|
||||||
async me(): Promise<{ logged_in: boolean; app_version?: string }> {
|
async me(): Promise<{ logged_in: boolean; app_version?: string; audit_log_enabled?: boolean }> {
|
||||||
const res = await fetch("/api/me", { credentials: "include" });
|
const res = await fetch("/api/me", { credentials: "include" });
|
||||||
return handle(res);
|
return handle(res);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user