I’m certain you can do this with a udev rule. I used something simmilair to prevent my laptop from waking when the screen flexes on the keyboard wile it is in a bag.
This article in the arch wiki might be helpful: https://wiki.archlinux.org/title/Power_management/Wakeup_triggers
I personally run authelia. I prefer the config file over a gui where i have to click everything together. For the actual user storage i got lldap.
But my requirements a possibly different to yours, my main focus was no docker and no javascript backend.
Keycloak is definetly overkill for a homelab. Both in effort to get it to run, and maintaining it.