SSO with OAuth2.0 and OIDC
LangSmith Self-Hosted provides SSO via OAuth2.0 and OIDC. This will delegate authentication to your Identity Provider (IdP) to manage access to LangSmith.
Our implementation supports almost anything that is OIDC compliant, with a few exceptions. Once configured, you will see a login screen like this:
With Client Secret (Recommended)
By default, LangSmith Self-Hosted supports the Authorization Code
flow with Client Secret
.
In this version of the flow, your client secret is stored security in the LangSmith platform (not on the frontend) and used for authentication and establishing auth sessions.
Requirements
You may upgrade a basic auth installation to this mode, but not a none auth installation. In order to upgrade, simply remove the basic auth configuration and add the required configuration parameters as shown below. Users may then login via OAuth only. In order to maintain access post-upgrade, you must have access to login via OAuth using an email address that previously logged in via basic auth.
LangSmith does not support moving from SSO to basic auth mode in self-hosted at the moment. We also do not support moving from OAuth Mode with client secret to OAuth mode without a client secret and vice versa. Finally, we do not support having both basic auth and OAuth at the same time. Ensure you disable the basic auth configuration when enabling OAuth.
- Your IdP must support the
Authorization Code
flow withClient Secret
. - Your IdP must support using an external discovery/issuer URL. We will use this to fetch the necessary routes and keys for your IdP.
- You must provide the
OIDC
,email
, andprofile
scopes to LangSmith. We use these to fetch the necessary user information and email for your users. - You will need to set the callback URL in your IdP to
http://<host>/api/v1/oauth/custom-oidc/callback
, where host is the domain or IP you have provisioned for your LangSmith instance. This is where your IdP will redirect the user after they have authenticated. - You will need to provide the
oauthClientId
,oauthClientSecret
,hostname
, andoauthIssuerUrl
in yourvalues.yaml
file. This is where you will configure your LangSmith instance.
- Helm
- Docker
config:
authType: mixed
hostname: https://langsmith.example.com
oauth:
enabled: true
oauthClientId: <YOUR CLIENT ID>
oauthClientSecret: <YOUR CLIENT SECRET>
oauthIssuerUrl: <YOUR DISCOVERY URL>
oauthScopes: "email,profile,openid"
# In your .env file
AUTH_TYPE=mixed
LANGSMITH_URL=https://langsmith.example.com
OAUTH_CLIENT_ID=your-client-id
OAUTH_CLIENT_SECRET=your-client-secret
OAUTH_ISSUER_URL=https://your-issuer-url
OAUTH_SCOPES=email,profile,openid
Session length controls
All of the environment variables in this section are for the platform-backend
service and can be added using platformBackend.deployment.extraEnv
in Helm.
- By default, session length is controlled by the expiration of the identity token returned by the identity provider
- Most setups should use refresh tokens to enable session length extension beyond the identity token expiration up to
OAUTH_SESSION_MAX_SEC
, which may require including theoffline_access
scope by adding tooauthScopes
(Helm) orOAUTH_SCOPES
(Docker) OAUTH_SESSION_MAX_SEC
(default 1 day) can be overridden to a maximum of one week (604800
)- For identity provider setups that don't support refresh tokens, setting
OAUTH_OVERRIDE_TOKEN_EXPIRY="true"
will takeOAUTH_SESSION_MAX_SEC
as the session length, ignoring the identity token expiration