unreality / nCryptAgent

An SSH agent for hardware backed keys on Windows
Apache License 2.0
41 stars 4 forks source link

nCryptAgent popup appears, current maximized window resizes and message appears #15

Open soywiz opened 9 months ago

soywiz commented 9 months ago

https://github.com/unreality/nCryptAgent/assets/570848/dfbe6670-803c-4e1c-a598-9064746932c8

Would it be possible to prevent that behaviour from happening? I believe this is program is super useful as I come from mac with Secretive. I have tried to clone the repo and I was able to remove the message, but since I don't have GO experience coudln't figure out how to prevent the current window change its size or nCryptAgent dialog appearing.

unreality commented 9 months ago

I'll try do some investigation, i imagine by stealing focus ncrypt forces the other app out of maximised mode. Perhaps some improvements to the focus-stealing logic can be done as well (eg if the pin cache is still in effect, dont steal focus)

soywiz commented 9 months ago

What's the reason nCryptAgent requires stealing the focus when a key operation is requested?

unreality commented 9 months ago

If nCryptAgent doesnt take focus, the PIN prompt for smartcards, or FIDO2 authentication prompt etc, pops under the current window, and its not clear the operation requires user interaction to proceed. Taking focus forces those UI prompts to be visible to the user.

If you have no PIN etc then stealing focus is not required. Im unsure whether this can be determined without requesting an operation though.

soywiz commented 9 months ago

Thanks for the clarification, it makes sense. Could it be possible to add a checkbox in the settings to disable the focus? I don't have pin there and if I had, it would be okay to switch the focus manually once per session.

unreality commented 8 months ago

@soywiz try pre-release v0.0.7, and let me know if it fixes the issue for you. If your key has no PIN/Password you can set noPin to true for your key in %AppData%\nCryptAgent\config.json and it will no longer take focus, but it should return focus correctly, leaving windows maximised if they were already even without doing this.

soywiz commented 8 months ago

Nice! verified that the current fullscreen app doesn't restore Thanks!

I have noticed a few things:

Here's a small video showing this:

https://github.com/unreality/nCryptAgent/assets/570848/848123dc-2cc7-4e8a-b785-fd929e51a907

In any case, just by not restoring the window size it has improved a lot. Thanks you very much for looking into this 👏🙏!