Authentication
Last updated
Last updated
Authentication is available in Phoenix 5.0
By default Phoenix deploys with authentication disabled as you may be just trying Phoenix for the very first time or have Phoenix deployed in a VPC. However you might want to further protect access to your data via authentication. Below are the steps.
Authentication will stop collecting traces and block all API access until API keys are created. For that reason we recommend scheduling some downtime if you have already deployed phoenix.
To enable authentication on your Phoenix, you will have to set two environment variables:
Variable | Description | Example Value |
---|---|---|
PHOENIX_ENABLE_AUTH | Set to | True or False |
PHOENIX_SECRET | A long string value that is used to sign JWTs for your deployment. It should be a good mix of characters and numbers and should be kept in a secret store of some kind. |
|
The following environment variables are optional but recommended:
PHOENIX_USE_SECURE_COOKIES | If set to True, access and refresh tokens will be stored in secure cookies. Defaults to False. |
PHOENIX_CSRF_TRUSTED_ORIGINS | A comma-separated list of origins allowed to bypass Cross-Site Request Forgery (CSRF) protection. This setting is recommended when configuring OAuth2 clients or sending password reset emails. If this variable is left unspecified or contains no origins, CSRF protection will not be enabled. In such cases, when a request includes |
Deploy Phoenix with the above environment variables set. You will know that you have setup authentication correctly if the UI navigates to to a login screen.
By default Phoenix will create an admin user account. To get started:
Log in as the admin user. The email should be admin@localhost and the password will be admin
Set a new password for admin. You will be prompted to set a new password. Use a sufficiently complex password and save it in a safe place.
Go to the settings page on the left nav and create your first system API key. This API key can be used to log traces, use the Phoenix client, and programmatically hit Phoenix's APIs. Store the system API key in a safe place.
In your application code, make sure to set the proper authentication headers with the system API key. Phoenix respects headers in the form of bearer auth, meaning that you should set the header in the form Authorization: Bearer <token>. Note that if you are using the Phoenix Client or Phoenix Otel, you simply need to set the PHOENIX_API_KEY environment variable.
Re-deploy your application with the API key created above and you will see traces stream in as before.
The following environment variables are optional but recommended:
Users can be added and removed from a Phoenix instance with authentication enabled. Users have one of two roles admin
or member
, see permissions below to learn more about the permissions for each role.
Only admins can manage phoenix users. They can add, delete, and reset the passwords of other members. To manage users go to the /settings
page.
Deleting a user results in permanently blocking them from phoenix. The action cannot be undone and the user cannot be reactivated with the same email or username. Please be careful when deleting users.
This section outlines the specific actions that users can perform based on their assigned roles within the system: Admin and Member. The permission matrix is divided into two main categories:
Mutations: Operations that allow users to create, update, or delete data within the system.
Queries: Operations that enable users to retrieve or view data from the system.
Mutations are operations that enable users to create, update, or delete data within the system. This permission matrix ensures that only authorized roles can execute sensitive actions, such as managing users and API keys, while allowing members to perform essential account-related updates like changing their own passwords and usernames.
Neither an Admin nor Member is permitted to change email addresses.
Action | Admin | Member |
---|---|---|
Create User | ✅ Yes | No |
Delete User | ✅ Yes | No |
Change Own Password | ✅ Yes | ✅ Yes |
Change Other's Password | ✅ Yes | No |
Change Own Username | ✅ Yes | ✅ Yes |
Change Other's Username | ✅ Yes | No |
Create System API Keys | ✅ Yes | No |
Delete System API Keys | ✅ Yes | No |
Create Own User API Keys | ✅ Yes | ✅ Yes |
Delete Own User API Keys | ✅ Yes | ✅ Yes |
Delete Other's User API Keys | ✅ Yes | No |
Queries are operations that allow users to retrieve and view data from the system.
This table only shows actions that a Member is not permitted to do. Actions without restrictions are omitted.
Action | Admin | Member |
---|---|---|
List All System API Keys | ✅ Yes | No |
List All User API Keys | ✅ Yes | No |
List All Users | ✅ Yes | No |
Fetch Other User's Info, e.g. emails | ✅ Yes | No |
There are two kinds of API keys in Phoenix: system
and user
.
System keys act on behalf of the system as a whole rather than any particular user. They can only be created by admins, are not meaningfully associated with the admin who creates them except for auditing purposes, and do not disappear if that admin is deleted. A system key would be the recommended kind of key to use in programmatic interactions with Phoenix that do not involve a user (e.g., automated flows querying our REST APIs).
User API keys are associated with and act on behalf of the user to which they are issued. That user has the ability to view and delete their own user keys, and if the user is deleted, so are all of their associated user keys. A user might create their own user key into order to run an experiment in a notebook, for example.
Phoenix API keys can be set with the PHOENIX_API_KEY
environment variable:
If authentication is enabled on Phoenix, all interactions with the server need to include an authorization
header. Phoenix will read the PHOENIX_API_KEY
environment variable, and automatically include it as an authorization
header. Interactions with Phoenix include:
Using phoenix.Client
Runing experiments
Sending OpenInference traces (more details below)
API Keys also need to be included on OpenInference traces sent to the Phoenix server. If you've set the PHOENIX_API_KEY
environment variable, the phoenix.otel
module will automatically include an authorization
header with the API key:
Alternatively, you can explicitly set the authorization
header on the exporter if using OpenTelemetry primitives directly.
If setting authorization
headers explicitly, ensure that the header field is lowercased to ensure compatibility with sending traces via gRPC
The password recovery methods described in this section apply when recovering a locally authenticated user's password. In order recover a password for a user logged in via a third-party identity provider such as Google, you will have to consult the documentation of these identity providers
Using SMTP ensures that your password recovery emails are delivered reliably and securely. SMTP is the standard protocol for sending emails, making sure that you receive the reset link promptly in your inbox.
Below is an example configuration to enable SMTP for sendgrid
.
If SMTP is not configured, you have a few options to recover your forgotten password:
Contact an administrator and request that they reset your password. Admins can reset user passwords on the settings
page.
As a last resort, you can manually update the database tuple that contains your password salt and hash.
Phoenix supports login via third-party identity providers (IDPs), including:
Microsoft Entra ID (previously known as Azure Active Directory)
IDPs that support OpenID Connect and a well-known configuration endpoint at GET /.well-known/openid-configuration
OAuth2 enables applications such as Phoenix to authorize access to resources via identity providers (IDPs) rather than storing and verifying user credentials locally. OpenID Connect is an extension of OAuth2 that additionally authenticates users by verifying identity and providing Phoenix with user information such as email address, username, etc. Phoenix integrates with OpenID Connect IDPs that have a "well-known configuration endpoint" at GET /.well-known/openid-configuration
, which provides a standardized way to discover information about the IDP's endpoints and capabilities.
Phoenix uses the OAuth2 authorization code flow for web applications, which requires setting a few environment variables in addition to PHOENIX_ENABLE_AUTH
and PHOENIX_SECRET
:
Environment Variable | Description |
---|---|
PHOENIX_OAUTH2_<IDP>_CLIENT_ID | The client ID generated by the IDP when registering the application. |
PHOENIX_OAUTH2_<IDP>_CLIENT_SECRET | The client secret generated by the IDP when registering the application. |
PHOENIX_OAUTH2_<IDP>_OIDC_CONFIG_URL | The URL to the OpenID Connect well-known configuration endpoint. Entering this URL in your browser will return a JSON object containing authorization server metadata. |
Detailed instructions for common IDPs are provided below.
Users that sign into Phoenix via an OAuth2 IDP are initially added as members. Their role can be changed after their first login by a Phoenix admin.
In Google Cloud Console, select a GCP project in which to register your Phoenix OAuth2 app.
Select APIs and Services.
In the Credentials page, click on Create Credentials and select OAuth Client ID.
From the Application type dropdown, select Web application.
Enter a name for your Phoenix app, which will be displayed to users when signing in.
Under Authorized JavaScript origins, click Add URI and enter the origin URL where you will access Phoenix in the browser.
Under Authorized redirect URIs, click Add URI. Take the URL from the previous step and append the slug /oauth2/google/tokens
. Enter this URL.
Copy your client ID and client secret.
Deploy Phoenix with the three environment variables described above, substituting GOOGLE
for <IDP>
. The well-known configuration endpoint is https://accounts.google.com/.well-known/openid-configuration
.
In the AWS Management Console, navigate to the Cognito page.
From the User Pools page, select Create User Pool.
Under Required attributes, in the Additional required attributes dropdown, select email (you can optionally require name and picture to ensure user profiles have this information in Phoenix).
In the Initial app client section:
Under App type, select Confidential client.
Under App client name, enter a name for your Phoenix app.
Under Client secret, ensure Generate a client secret is selected.
Create your user pool and navigate to the page for the newly created user pool by clicking on its name.
Add at least one user to your user pool in the Users section.
Copy and save your user pool ID from the top of the page. The ID should be of the form <region>_<hash>
, e.g., us-east-2_x4FTon498
.
Under App Integration > Domain, create a domain to contain the sign-in page and OAuth2 endpoints.
Under App Integration > App client list > App clients and analytics, select your newly created client.
Copy and save your client ID and client secret.
Under Hosted UI, click Edit. On the Edit Hosted UI page:
Add an Allowed callback URL of the form <origin-url>/oauth2/aws_cognito/tokens
, where <origin-url>
is the URL where you will access Phoenix in the browser.
In the Identity Providers dropdown, select Cognito user pool.
Under OAuth 2.0 grant types, select Authorization code grant.
Under OpenID Connect scopes, select OpenID, Email, and Profile.
Save your changes.
The well-known configuration endpoint is of the form https://cognito-idp.<region>.amazonaws.com/<user-pool-id>/.well-known/openid-configuration
, where the user pool ID was copied in a previous step and the region is the first part of the user pool ID preceding the underscore. Test this URL in your browser to ensure it is correct before proceeding to the next step.
Deploy Phoenix using the three environment variables described above, substituting AWS_COGNITO
for <IDP>
.
From the Azure portal, navigate to Microsoft Entra ID.
Select Add > App Registration.
On the Register an Application page:
Enter a name for your application.
Under Redirect URI, in the Select a platform dropdown, select Web and a redirect URI of the form <origin-url>/oauth2/microsoft_entra_id/tokens
, where <origin-url>
is the URL where you will access Phoenix in the browser.
Copy and save the Application (client) ID.
Under Endpoints, copy and save the well-known configuration endpoint under OpenID Connect metadata document.
Under Client credentials, click Add a certificate or secret. Create a client secret and copy and save its value.
Deploy Phoenix using the three environment variables described above, substituting MICROSOFT_ENTRA_ID
for <IDP>
.
Phoenix can integrate with any OAuth2 IDP that supports OpenID Connect and has a well-known configuration endpoint. Detailed instructions will vary by IDP, but the general steps remain the same:
Register a Phoenix client application with your IDP. If prompted to select an application type, select traditional web application or a similarly named application type that allows you to generate a client secret in addition to a client ID.
Find the well-known configuration endpoint for your IDP.
Deploy Phoenix with the environment variables described above, substituting <IDP>
with your IDP name, e.g., AUTH0
.
Phoenix will make a best-effort attempt to display a readable name for your IDP on the login page based on the value substituted in the previous step. If you wish to customize the display name, for example, if your IDP name contains special characters, you may optionally configure the IDP name to be displayed with the PHOENIX_OAUTH2_<IDP>_DISPLAY_NAME
environment variable.