feat: handle PAM password policy changes
This commit is contained in:
34
rust/main.rs
34
rust/main.rs
@@ -13,6 +13,7 @@ use std::{
|
||||
use clap::Parser;
|
||||
use latchd_auth::AuthService;
|
||||
use latchd_core::{
|
||||
audit::{AuditAction, AuditEvent},
|
||||
config::{self, Config},
|
||||
error::{Error, ResultExt},
|
||||
session,
|
||||
@@ -173,8 +174,39 @@ fn run() -> Result<(), Error> {
|
||||
}
|
||||
};
|
||||
info!(user = %identity.username, session = %selection.session.title, "starting session");
|
||||
let audit = AuditEvent::started(AuditAction::Session, &identity.username);
|
||||
tracing::info!(
|
||||
target: "latchd.audit",
|
||||
action = %audit.action,
|
||||
outcome = %audit.outcome,
|
||||
account = %audit.account,
|
||||
pam_reason = ?audit.pam_reason,
|
||||
session = %selection.session.title,
|
||||
"security event"
|
||||
);
|
||||
if let Err(error) = auth.run_session(selection.ticket, spec) {
|
||||
error!(%error, "session ended with an error");
|
||||
let audit = AuditEvent::failed(AuditAction::Session, &identity.username, &error);
|
||||
tracing::info!(
|
||||
target: "latchd.audit",
|
||||
action = %audit.action,
|
||||
outcome = %audit.outcome,
|
||||
account = %audit.account,
|
||||
pam_reason = ?audit.pam_reason,
|
||||
session = %selection.session.title,
|
||||
"security event"
|
||||
);
|
||||
error!("session ended with an error; see the structured audit event");
|
||||
} else {
|
||||
let audit = AuditEvent::succeeded(AuditAction::Session, &identity.username);
|
||||
tracing::info!(
|
||||
target: "latchd.audit",
|
||||
action = %audit.action,
|
||||
outcome = %audit.outcome,
|
||||
account = %audit.account,
|
||||
pam_reason = ?audit.pam_reason,
|
||||
session = %selection.session.title,
|
||||
"security event"
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user