We have 300.000 users so we don't create users in AEM, we use sso for
publish login.Check this:
https://github.com/Adobe-Consulting-Services/acs-aem-samples/tree/master/bundle/src/main/java/com/adobe/acs/samples/authentication/impl
For custom forms authentication:Create a login page with a formValidate
username/password against to your database or other idp system on form
postAssign a secure authentication cookieCheck authentication cookie on
web server, redirect user to login page if not authen...