Overview
Pensar Apex includes a specialized AuthenticationAgent that handles complex authentication flows automatically. It supports:- Form-based authentication (username/password POST)
- JSON API authentication (REST API login)
- HTTP Basic/Bearer authentication
- OAuth 2.0 flows (authorization code, implicit, device code)
- Browser-based authentication (SPAs, JavaScript-rendered forms)
- Email verification (automated inbox checking)
- Multi-factor authentication (when possible)
- CSRF token handling
The authentication agent operates fully autonomously—no human intervention required. It discovers login endpoints, handles redirects, extracts session cookies, and exports credentials for downstream testing.
Quick Start
1
Provide Credentials to Apex
During session creation, pass authentication credentials:
2
Run Authentication Agent
3
Use Authenticated Session
After successful authentication, the session contains exportable cookies and headers:
How Authentication Works
Credential Management
Apex uses a CredentialManager to securely handle credentials without exposing raw passwords to the AI:Authentication Flow
The AuthenticationAgent follows a deterministic strategy:1
Detect Auth Mechanism
If no Indicators:
loginUrl is provided, the agent probes the target:- 401/403 → API authentication
- 302 redirect to /login → Form-based auth
- WWW-Authenticate header → HTTP Basic/Bearer
- JSON error → REST API auth
2
Attempt Authentication
Based on detection, the agent tries:API Path:Browser Path (for SPAs/OAuth):
3
Validate Session
After authentication, the agent validates the session:If successful, returns user data. If 401, auth failed.
4
Export Credentials
The agent calls This writes
complete_authentication to persist credentials:auth-data.json to the session directory for reuse.Authentication Methods
Form-Based Authentication
For traditional HTML login forms:- POST credentials to the login form endpoint
- Extract session cookies from
Set-Cookieheaders - Validate the session by making an authenticated request
JSON API Authentication
For REST APIs:- POST JSON:
{"email": "user@example.com", "password": "password123"} - Extract bearer token from response:
{"token": "eyJhbGc..."} - Export header:
{"Authorization": "Bearer eyJhbGc..."}
Browser-Based Authentication (SPAs)
For single-page apps with JavaScript-rendered forms:- Launch a headless browser with Playwright
- Navigate to the login page
- Fill the form fields using accessibility tree refs
- Click the submit button
- Extract cookies (including httpOnly)
- Extract tokens from
localStorage/sessionStorage
Browser automation is automatic—Apex detects when JavaScript rendering is required.
OAuth 2.0 Flows
For OAuth providers:- Navigate to the OAuth authorization URL
- Fill consent form if needed
- Handle redirect back to the app
- Extract authorization code from URL
- Exchange code for access token
- Export bearer token for API requests
Email Verification
For flows that require email confirmation:- Register a new account
- Use
email_search_messagesto find the verification email - Extract the verification link from the email body
- Navigate to the link to confirm the account
- Log in with the verified credentials
Email verification is fully automated using the Gmail or Outlook adapter. See Email Tools below.
Authentication Tools
The AuthenticationAgent has access to these specialized tools:API Authentication
authenticate_session
Performs credential-based authentication:
Browser Authentication
browser_navigate
Loads a page in the headless browser:
browser_snapshot
Captures the accessibility tree with element refs:
browser_fill
Fills a form field using its ref:
browser_click
Clicks a button or link:
browser_get_cookies
Extracts all cookies (including httpOnly):
browser_evaluate
Runs JavaScript to extract tokens:
Email Verification Tools
WhenemailInboxes are configured in the session:
email_list_inboxes
Lists available email inboxes:
email_search_messages
Searches for emails matching a query:
email_get_message
Fetches full email content:
Completion Tools
complete_authentication
Persists authentication data for downstream agents:
~/.pensar/sessions/<session>/auth/auth-data.json:
Auth Barriers
The agent detects and reports authentication barriers:
When a barrier is encountered:
CAPTCHA and MFA are reported as failures—Apex operates autonomously and cannot solve human challenges.
Best Practices
1. Use Credential Manager (Automatic)
Always provide credentials viaauthCredentials in the session config:
2. Provide Auth Hints
Help the agent by providing hints when known:3. Review Auth Data
After successful authentication, review the exported data:- Cookies are present and valid
- Headers include bearer tokens if needed
- Strategy matches the expected auth method
4. Test Authenticated Endpoints
Use the exported credentials for subsequent testing:Examples
Testing OAuth Flow
Testing Email Verification
Next Steps
Blackbox Testing
Test authenticated endpoints with blackbox testing
Whitebox Testing
Analyze authentication logic in source code
Docker Setup
Run authenticated tests in the Kali container
vLLM Setup
Use local models for authentication testing

