All documentation

Organization SSO with Ergo

Connect Mango to your own IRC network using your organization’s accounts.

Before you start

Organization SSO is a preview for Mango on Mac, iPhone, and iPad. Use a Mango build that includes Organization SSO and a fresh Ergo instance with a TLS certificate your devices trust. The steps below use stock Ergo 2.19.1 and an Authentik installation that supports cross-provider token introspection.

Mango opens the browser for OpenID Connect sign-in using Authorization Code with PKCE. It presents the resulting access token to your Ergo instance using SASL OAUTHBEARER over verified TLS. Ergo asks Authentik whether the token is active and which IRC account it belongs to. Ergo account configuration · SASL OAUTHBEARER

Use existing company accounts

If your company already has a directory, configure it as a sign-in source in Authentik. Employees sign in with their work accounts. Authentik issues the access token that Ergo checks. Use the same Mango and Ergo settings below, and assign an irc_account value to each permitted user in Authentik.

Microsoft Entra ID and Google Workspace

  • Microsoft 365 uses Microsoft Entra ID for work accounts. Add your company’s Entra tenant as an Authentik OAuth source and grant access to the Mango application to your pilot group. Entra ID setup in Authentik
  • Google Workspace can sign users in to Authentik through SAML. Enable the SAML app for your pilot users in Google Admin. Mango still receives its OpenID Connect token from Authentik. Google Workspace setup in Authentik

Okta

Register Authentik as an OIDC web app in Okta. Use the Authentik OAuth source’s callback URL as the app’s redirect URI, then assign the employees who should use IRC. In Authentik, configure the OAuth source with the Okta discovery URL and the web app’s client credentials. Then continue with the public Mango client and confidential Ergo client below. Authentik OAuth sources

A direct Okta-to-Ergo setup is a separate integration to validate. It needs an Okta custom authorization server for your IRC service. Verify that Ergo can introspect Mango’s public-client token and that the endpoint accepts only access tokens issued for this IRC service. Ergo uses the returned username as the account name. Okta’s example returns an email-style username, so a server-side adapter may be needed to map it to a stable IRC account. The Integrator Free Plan includes a custom authorization server for testing. Production use can require the API Access Management add-on. Okta authorization servers · Okta introspection example

Set up Authentik

Create the public Mango client

  1. Add an OAuth2/OpenID provider with client type Public and bind it to an application, for example mango-irc. Bind the application to a pilot group so only your test users can sign in.
  2. Enable only the Authorization Code grant and register mango://organization/sign-in as an exact redirect URI. Use the per-provider issuer mode.
  3. Assign the openid scope mapping and the profile mapping described below. Enable Include claims in ID token so Authentik includes the mapped username in token introspection.
  4. Copy the public Client ID and the exact issuer from the provider’s discovery document. For the example application, the discovery URL is https://sso.example.com/application/o/mango-irc/.well-known/openid-configuration and the issuer is usually https://sso.example.com/application/o/mango-irc/. Keep the trailing slash if the issuer includes it.

Use a short access-token lifetime. Keep refresh-token issuance off for this application because Authentik can also report refresh tokens as active during introspection. Authentik OAuth2 provider settings

Map users to IRC accounts

Ergo looks for a top-level username in the introspection response. Give each pilot user a unique, administrator-managed irc_account attribute such as alice. Use a stable, IRC-compatible account name that stays with the user if their email or display name changes.

Create an Authentik Scope Mapping with the scope name profile and assign it to the Mango provider. This expression returns the account name. Ergo rejects an empty username, so users with a missing mapping cannot sign in.

python
return {"username": user.attributes.get("irc_account", "")}

Before enabling automatic account creation on an existing network, verify each mapping against the current IRC account owner and check for case-insensitive name collisions. Authentik scope mappings · Ergo’s introspection implementation

Create the confidential Ergo client

  1. Create a second OAuth2/OpenID provider with client type Confidential, dedicated to Ergo’s introspection requests.
  2. Open the public Mango provider and select the confidential Ergo provider in Federated OAuth2/OpenID Providers. This authorizes Ergo to check tokens issued for Mango.
  3. Store the confidential provider’s client ID and secret on the Ergo host. The Mango app uses the public provider’s issuer and client ID.

Authentik cross-provider introspection

Configure Ergo

Merge the following keys into your Ergo configuration’s existing accounts block. This example requires SASL for all connections to a fresh pilot network and creates IRC accounts on first successful sign-in. Replace the example domain and read the confidential credentials from your Authentik setup.

yaml
accounts:
  authentication-enabled: true
  registration:
    enabled: false
  require-sasl:
    enabled: true
    exempted: []
  oauth2:
    enabled: true
    autocreate: true
    introspection-url: "https://sso.example.com/application/o/introspect/"
    introspection-timeout: 10s
    client-id: "<Ergo confidential client ID>"
    client-secret: "<Ergo confidential client secret>"

Start Ergo with its TLS listener enabled. Make sure the server can reach Authentik’s introspection endpoint over HTTPS. Keep the configuration containing the secret in server-side storage.

Connect in Mango

  1. In the first-run connection choices, select Sign in with your organization. For an existing network, open its editor and select Authentication → Mechanism → Organization SSO.
  2. Enter the IRC host and TLS port, such as irc.example.com on port 6697. Enable TLS and keep certificate verification on.
  3. Enter the public provider’s OIDC issuer URL and OAuth client ID. Select Sign in with your organization and complete the browser flow.
  4. After Mango shows Organization sign-in complete, choose Save and Connect for a new network. For an existing network, save the edits and connect from the sidebar.

Verify the connection

  • Sign in as a pilot user and confirm that Ergo logged you into the account from irc_account. Run /whois <your-nickname> and check the account in the response.
  • Try a directory user outside the pilot group and confirm that Authentik denies access.
  • Reconnect while the token is valid, then try once more after it expires. The preview keeps tokens in memory and stores the network profile on the device. Reconnecting after expiry or restarting Mango requires another browser sign-in. Disconnect active IRC sessions on the server if you need immediate offboarding.

Troubleshooting

  • The browser never opens. Check that Mango can reach discovery over HTTPS and that the entered issuer exactly matches the discovery document’s issuer.
  • Authentik rejects the redirect. Check that the public provider allows mango://organization/sign-in exactly.
  • The browser signs in, then Ergo rejects the connection. Confirm that the public provider lists the confidential Ergo provider for cross-provider introspection. Check that introspection returns active: true and a non-empty username for the test user, and check the TLS setting and OAUTHBEARER support on the Ergo listener.