Skip to content

auth: add Visage face authentication module#1010

Open
SomeCodecat wants to merge 1 commit into
hyprwm:mainfrom
SomeCodecat:visage-auth
Open

auth: add Visage face authentication module#1010
SomeCodecat wants to merge 1 commit into
hyprwm:mainfrom
SomeCodecat:visage-auth

Conversation

@SomeCodecat
Copy link
Copy Markdown

Adds a parallel face-auth backend that talks directly to Visage's system D-Bus interface (org.freedesktop.Visage1) instead of going through pam_visage.so. This mirrors the approach taken for fingerprint in #514: PAM modules are evaluated as soon as pam_authenticate starts, which means the face check fires the instant the lock appears and unlocks immediately if a face is in front of the camera. Direct D-Bus integration lets us add a small start_delay after lock and gate retries on a condvar so submitting input nudges a fresh attempt.

A worker thread polls Verify(username) and on a match calls g_pAuth->enqueueUnlock(). PAM continues to run in parallel as before, so password unlock works unchanged.

Disabled by default. Enable with auth.visage.enabled = 1. Other knobs are ready_message, retry_delay (default 500 ms), and start_delay (default 2000 ms).

Verify calls are bounded with withTimeout(30s) so a hung daemon can't deadlock terminate(). On D-Bus errors the worker backs off exponentially up to 5 s and never permanently gives up — visaged commonly takes 30–90 s to come back after a hibernate resume on Surface devices, and the user may also be waiting on visage-resume.service to restart it. If visaged isn't running at hyprlock start, the worker retries the connection every 2 s.

I did not add a PrepareForSleep handler like fingerprint has. The retry loop recovers organically once visaged is reachable again, so it didn't seem worth the extra dbus connection. Happy to add it if you'd rather mirror the fingerprint structure exactly.

Comment thread src/auth/Visage.hpp
Comment on lines +44 to +45
std::atomic<bool> m_bAbort{false};
std::atomic<bool> m_bAuthenticated{false};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the "legacy" way that hypr* named member vars. Can you change it to the new "m_" format?

At some point I would like to bulk change all of the var names, but I don't want to disrupt open PRs...

Comment thread src/auth/Visage.cpp

void CVisage::init() {
m_sPrompt = m_sReadyMessage;
m_thread = std::thread([this] { workerLoop(); });
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fingerprint auth implementation doesn't need it's own thread, because it uses async method calls.
Is there a reason visage needs a thread?
I would prefer if visage would also handle it like that.

But for this to work, we need to pull out the dbus connection object from fingerprint (add g_dbus) so that we can reuse the same connection here and only need one connection.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you would be up to pull out the dbus connection from fingerprint. If not I can do it and you can rebase your branch on top of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants