SSO for any OIDC or SAML app
Any product with "Sign in with SSO", and any app you build with an OpenID Connect or SAML library, can use Trowyn.
OpenID Connect (most apps and frameworks)
- In the console, SSO → Add app → OpenID Connect. - Confidential for server-side apps (they keep the client secret). - Public for single-page and mobile apps (no secret; PKCE required).
- Add your app's exact redirect URIs, for example
https://app.example.com/auth/callback. - Give your library the issuer (or the discovery URL), the client ID and, for confidential
clients, the client secret. Request the scopes
openid email profile.
Most libraries need nothing else. A minimal example with openid-client (Node):
import * as client from "openid-client";
const config = await client.discovery(new URL("https://trowyn.com/sso/<org id>/test"), "trw_oidc_test_…", process.env.TROWYN_CLIENT_SECRET);
const verifier = client.randomPKCECodeVerifier();
const url = client.buildAuthorizationUrl(config, {
redirect_uri: "https://app.example.com/auth/callback", scope: "openid email profile",
code_challenge: await client.calculatePKCECodeChallenge(verifier), code_challenge_method: "S256", state: "…",
});
// …redirect the browser to url; on the callback:
const tokens = await client.authorizationCodeGrant(config, callbackUrl, { pkceCodeVerifier: verifier, expectedState: "…" });
console.log(tokens.claims().sub); // the user's external_user_id
Check in your app: the ID token's signature (from the JWKS), iss, aud, exp and nonce. Your
library does this. Use sub as the user's identifier; it's the external_user_id you linked.
SAML
- Get the service provider's Entity ID (also called Audience URI or SP issuer) and ACS URL from the product's SSO settings.
- In the console, SSO → Add app → SAML with those values. Pick the NameID format the
product expects (
emailAddressif it asks for an email). - Give the product Trowyn's details: the metadata URL (easiest, if it accepts one), or the
SSO URL, Entity ID / issuer and the certificate (
certificate.pem). - Map any attributes the product needs (for example
firstName,email) in the app's attribute mapping.
For IdP-initiated sign-in (a bookmark or portal tile), use
https://trowyn.com/sso/<org id>/<env>/saml/idp/<app id>, optionally with ?RelayState=…. You can
turn IdP-initiated sign-in off per app.
Troubleshooting
| Message on trowyn.com/signin | Fix |
|---|---|
| Unknown app (client_id) | Wrong client ID, the app is disabled, or it belongs to the other environment |
| Redirect URI isn't registered | Add the exact URL (scheme, host, path, query) to the app |
| Service provider isn't registered | The AuthnRequest's Issuer must equal the Entity ID you registered |
| ACS URL that isn't registered | Add the ACS URL the service provider sends |
| Not valid in this browser | The sign-in started in another browser, or cookies are blocked |
| Took too long | Sign-ins expire after 10 minutes: start again from the app |