Perhaps you could use an api gateway that will redirect the initial requet to a single sign on service linked to your database where the users are stored and where you will do your authentication process, and,then will forward the request to the targeted service if the authentication is succesfull?