Look into Authorizer.dev and octauthent.com.
Authorizer is open-source, self-hosted and can be deployed on Railway very easily. octauthent is a freemium service.
I’ve tried Authorizer, and it works with Publii. The developer of the project is very friendly and responsive on Discord.
It helped me to protect my personal decentralized website, thank you very much!
Now with your solution I am more protected!