Auth profiles
Auth profiles let the same API scenario run as different identities. Use them to test whether admins, regular users, viewers, unauthenticated clients, and invalid tokens get the right access.How they work
An environment can carry many named auth profiles. Each profile has its own credentials and login config. At run time, a scenario picks one profile and inherits that profile’s token for every step. A profile has two flavors:- API: posts credentials to a login endpoint and extracts a token from the response.
- UI: drives Playwright through the login form and captures storage state (plus sniffs a bearer token from network traffic for the API fallback).
staging environment:
A scenario that tests IDOR can run once as one
user, capture that user’s userId, then run as a different user profile and try to read the first user’s resource. The expected result is 403. If the API returns 200, the assertion fails and Qodex opens a critical finding.
Precedence
For API steps, the runner picks an auth source in this exact order:- Static
authTokenon the environment, if set directly. Overrides everything. - Cached bearer token if the cache is still fresh (TTL 30 minutes).
api_login_configon the environment (or the chosenauth_profile.login_config). Run the login, extract the token.- Browser fallback via
ui_login_steps. Drive Playwright through the login form, sniff the bearer token off the network.
ui_login_steps.
Inspect a cached token and credentials
When you need to debug a request by hand, expand the profile on the environment’s Auth Profiles list. The cached bearer token and the configured credentials, such as a client ID, are masked by default. Click Show to reveal a value, or Copy to copy it without revealing it on screen. The refresh token and captured session cookies are never shown. Use this only for short-lived inspection, such as confirming which role a request is using in the API Playground or comparing a failing scenario against a manual request. Treat the copied value like any other secret: do not paste it into docs, chats, issue trackers, or source control.Mint and test a token
For API auth profiles, click Get token on the profile after you configure the login request. Qodex sends the profile’s login request, extracts the token with the configuredtokenPath, and stores the result in the same short-lived cache used by scenario runs. If the login request fails, the profile shows the failure so you can correct the URL, body, headers, credentials, or token path before a scenario depends on it.
This is the fastest way to confirm that a profile is ready for the API Playground, authorization checks, and scheduled runs.
The Token cache section of the profile shows when the token was cached and when it expires. Click Expire now to mark the cached token expired, or Force refresh to clear it so the next scenario that needs auth runs the login again.
Credentials must resolve
A credential or login config value can reference a variable, such as${CLIENT_ID}, only from the same environment the profile is saved in. An API login config can also reference the profile’s own credential keys.
- At save time, Qodex refuses a profile that references a variable the environment does not define, and names the missing variable and the environment. Fix the variable name or add the variable to the environment, then save again.
- At run time, if a credential still carries an unresolved reference, the login does not start and the scenario fails with a message naming the problem. Qodex never sends an empty
Authorization: Bearerheader and then reports the resulting 401 as a bug in your API.
Manage environments and auth profiles
Open Environments under Context in the sidebar to manage an environment, its variables, and its auth profiles. To delete an environment, select it, click Delete, and confirm Delete. This cannot be undone. If you only need a variant, use Duplicate first so the hosts, variables, and login configuration are copied into a new environment. To edit an auth profile, select the environment, open Auth Profiles, expand the profile, and click Edit. The dialog opens pre-filled with the profile’s current settings, including profiles Qodex created from chat. Leave a secret field blank to keep the stored value. If the profile has settings the form does not show, the dialog lists them and keeps them when you save. Click Duplicate to create a variant under a new name. To delete an auth profile, expand it and click Delete, then confirm Delete profile. The profile and its cached session are removed from this environment. Scenarios that name the profile keep their reference, because a scenario refers to a profile by name and resolves it against whichever environment the run targets:- A run in another environment that has a profile with the same name still signs in normally.
- If you re-add a profile with the same name to this environment, those scenarios resolve it again.
- Until then, a run of one of those scenarios in this environment errors with a message that the profile is missing, instead of running unauthenticated.
Handle magic links and cookie-based sessions
Not every identity can sign in through an API token exchange. A UI auth profile can now manage an inbox-driven sign-in flow, including a magic link, and retain the browser session it establishes. Use this for passwordless login, email verification, or an application that authenticates only with session cookies:- Configure the UI login steps for the profile, including the email wait step when the app sends a sign-in link.
- Give the profile its own project inbox label so another profile cannot consume the same login message.
- Let Qodex open the matching link and verify that the resulting browser session is signed in.
OAuth 2.0 profiles
For OAuth 2.0 flows Qodex cannot start on its own, create the profile yourself: click + New profile, choose an API profile, and set Login type to OAuth 2.0: Client Credentials or OAuth 2.0: Authorization Code (browser redirect). An Authorization Code profile signs in through the provider in a popup when you click Connect (or Reconnect to mint a new refresh token). To pin the profile to one test account, fill in Account to connect. Qodex then asks the provider for that account and stores tokens only when that account signs in, even if your browser is signed in to the provider as someone else. The scope must includeopenid profile email so Qodex can read which account signed in. Leave the field blank to accept any account.
The api_login_config shape
The HTTP login configuration tells Qodex how to exchange credentials for a token.url: where to POST. Must resolve to an absolute URL after${var}substitution. Bare paths are rejected.method: usuallyPOST. The runner accepts any HTTP verb.headers: any headers the login endpoint needs. DefaultContent-Type: application/json.body: the request body. Plain JSON for most APIs, form-encoded for legacy.tokenPath: dot-notation JSONPath into the response body.data.access_tokenreadsresponse.data.access_token. The runner uses a small JSONPath subset, dots only. For exotic paths, write a postscript instead.
When this matters
The whole point of running tests as multiple identities is authorization correctness:- IDOR (insecure direct object reference): a
userprofile should not be able to read another user’s resources. Run the same scenario as two differentuserprofiles, capture an ID from one, request it as the other, assert 403. - BOLA (broken object-level authorization): same idea at the object level. List your orders as one user, then try to load one of those order IDs as another user.
- Role escalation: a
viewershould not be able to write. Run the write scenarios asviewerand assert 403 across the board. - Endpoint-level auth gating: an unauthenticated client should get 401 on protected routes. Use a profile with no token (or a deliberately invalid one) to assert that.
Sample environment with two profiles
On the roadmap
Related
Scenarios
See where step.auth attaches.
Chaining and postscripts
Capture tokens from a login response.
API Playground
Run requests with any auth profile.
Auto-verification on save
What gets checked the moment you save.