You can check the opensource developer portal in the GitHub repository.
https://github.com/Azure/api-management-developer-portal
You can run it locally or deploy to a web server and connect it to your Azure API Management service.
Particular authenticate method
https://github.com/Azure/api-management-developer-portal/blob/d04066dbc4fc85588576e6c4f772b136289f5252/src/services/usersService.ts#L34