Introduction
When building an internal AI assistant, getting the model to generate useful responses is only one part of the engineering challenge.
The application also needs to establish who is using it, verify that the user is authenticated, and prevent unauthenticated requests from reaching the backend.
This becomes particularly important when the frontend is a static JavaScript application. Unlike a traditional server-rendered application, a static frontend does not have a private backend in which to keep credentials or client secrets. Its JavaScript, configuration, and network requests are visible to anyone who can access the application.
For the Daara Media AI Creative Content Assistant, I wanted staff to authenticate before using the application, and I wanted the API to reject unauthorized requests independently of the frontend.
I implemented this using four key technologies:
Amazon Cognito for user authentication and managed login.
OAuth 2.0 Authorization Code Flow with PKCE for secure…