Integrate with OpenCode
Support level: Community
What is OpenCode?
OpenCode is an open source coding agent. Use it in the desktop app, in the terminal, on your phone or from your own code with the SDK.
Preparation
The following placeholders are used in this guide:
authentik.companyis the FQDN of the authentik installation.example.companyis the email domain that your OpenCode users sign in with.
This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application.
You must be an owner of the OpenCode Console workspace to configure SSO. Each workspace supports one SSO connection, using either OIDC or SAML.
Integration configuration
To support the integration of OpenCode with authentik, you need to create an application/provider pair in authentik. Select the tab for the protocol that you want to use.
- OIDC
- SAML
authentik configuration
In authentik versions earlier than 2026.5, all Redirect URIs are automatically treated as Authorization type. If you are using one of these older authentik versions, add only the Authorization URL to your Redirect URIs and do not configure a Post Logout URI.
Create an application and provider in authentik
-
Log in to authentik as an administrator and open the authentik Admin interface.
-
Navigate to Applications > Applications and click New Application to open the application wizard.
- Application: provide a descriptive name, an optional group for the type of application, the policy engine mode, and optional UI settings. Take note of the Slug value because it is required later.
- Choose a Provider type: select OAuth2/OpenID Provider as the provider type.
- Configure the Provider: provide a name (or accept the auto-provided name), the authorization flow to use for this provider, and the following required configurations.
- Take note of the Client ID and Client Secret values because they are required later.
- Temporarily add a Redirect URI of type
StrictAuthorizationashttps://temp.temp. - Select any available Signing Key.
- Configure Bindings (optional): you can create a binding (policy, group, or user) to manage the listing and access to applications on a user's Application Dashboard page.
-
Click Create Application to save the new application and provider.
OpenCode configuration
- Log in to the OpenCode Console as a workspace owner.
- Navigate to Settings > Security, click Configure SSO, and select OpenID Connect.
- Select the generic OIDC provider and set the following values:
- Issuer URL:
https://authentik.company/application/o/<application_slug>/ - Client ID: enter the Client ID from authentik.
- Client Secret: enter the Client Secret from authentik.
- Display Name:
authentik
- Issuer URL:
- Click Save, and then copy the Callback URL that OpenCode displays.
Update the authentik provider
- Return to the authentik Admin interface.
- Navigate to Applications > Providers and click the Edit icon of the OpenCode provider.
- Under Protocol settings, replace the temporary Redirect URI with the Callback URL from OpenCode.
- Click Save Changes.
authentik configuration
authentik 2026.5 introduces changes to how the SAML provider behaves. Specifically, the provider now automatically sets the Issuer value to: https://authentik.company/application/saml/<application_slug>/metadata/
Older versions of authentik set this value to authentik by default. If you're running an older version, please set Issuer to https://authentik.company/application/saml/<application_slug>/metadata/, where <application_slug> is the slug that you selected for the application.
Create an application and provider in authentik
-
Log in to authentik as an administrator and open the authentik Admin interface.
-
Navigate to Applications > Applications and click New Application to open the application wizard.
- Application: provide a descriptive name, an optional group for the type of application, the policy engine mode, and optional UI settings.
- Choose a Provider type: select SAML Provider as the provider type.
- Configure the Provider: provide a name (or accept the auto-provided name), the authorization flow to use for this provider, and the following required configurations.
- Temporarily set the ACS URL and Audience to
https://temp.temp. - Under Advanced protocol settings:
- Select any available Signing Certificate.
- Set NameID Property Mapping to
authentik default SAML Mapping: Email.
- Temporarily set the ACS URL and Audience to
- Configure Bindings (optional): you can create a binding (policy, group, or user) to manage the listing and access to applications on a user's Application Dashboard page.
-
Click Create Application to save the new application and provider.
Copy the metadata URL
- Navigate to Applications > Providers and click the name of the OpenCode provider.
- Under Related objects > Metadata, click Copy download URL. This URL is required in the next section.
OpenCode configuration
- Log in to the OpenCode Console as a workspace owner.
- Navigate to Settings > Security, click Configure SSO, and select SAML 2.0.
- Select the generic SAML provider, and then copy the ACS URL and SP Entity ID values that OpenCode displays.
- Add the identity provider metadata by URL, using the metadata URL that you copied from authentik.
- Keep the OpenCode setup flow open.
Update the authentik provider
- Return to the authentik Admin interface.
- Navigate to Applications > Providers and click the Edit icon of the OpenCode provider.
- Under Protocol settings, set the following values:
- ACS URL: set to the ACS URL from OpenCode.
- Audience: set to the SP Entity ID from OpenCode.
- Click Save Changes.
- Return to the OpenCode setup flow, review the details, and click Activate SSO.
Verify the email domain in OpenCode
OpenCode only redirects users to authentik when their email address belongs to a verified domain.
- In the OpenCode Console, navigate to Settings > Security.
- Under Email domains, click Add domain and enter
example.company. - Publish the TXT record that OpenCode displays with your DNS provider.
- Click Verify Domain. DNS changes can take some time to propagate.
Configuration verification
To confirm that authentik is properly configured with OpenCode, log out of the OpenCode Console and sign in with an example.company email address. You should be redirected to authentik and, after authenticating, redirected back to the OpenCode Console.
Use a workspace admin or member account to test. Workspace owners can still sign in without SSO, so that a misconfigured identity provider cannot lock them out.