
Yes, AI can add authentication to an application by integrating an established identity provider and implementing sign-in, sessions, account recovery, and protected routes. Authentication proves identity; it does not automatically decide what that identity may do. Authorization must be designed and enforced separately.
Define the full identity lifecycle:
- Registration, verification, sign-in, sign-out, and session expiration.
- Password reset or another supported recovery path.
- Roles, resource ownership, and server-side permission checks.
- Account disablement, deletion, and active-session revocation.
- Safe redirects, error messages, rate controls, and audit events.
Ask the agent for a threat-aware plan before it edits code. It should identify trust boundaries, where session data is validated, and which checks run on the server. Review every protected operation directly. A hidden page or button does not prevent an unauthorized request. Test expired sessions, changed roles, reused reset links, and access to another user's record.
Use maintained provider libraries and avoid asking the agent to invent encryption, token formats, or password storage. AI is useful for integration, repetitive guards, and test coverage. A human reviewer still owns the authorization rules and release decision. Start with one protected workflow, verify denial cases, and expand from a proven pattern.
Related reading: How to write requirements for an AI coding agent and How to validate AI-generated code.
