Skip to content

SSO (Single Sign-On)

Single Sign-On (SSO) allows users on your team to log in to Mahadata using an existing identity provider (IdP) — Okta, Microsoft Entra ID (formerly Azure AD), Google Workspace, OneLogin, Keycloak, Auth0, or any other IdP that supports SAML 2.0 / OpenID Connect (OIDC).

This guide is intended for:

  • Tenant Admin customer portal. Mahadata who want to enable SSO. Configuration is done in Settings → SSO — staff
  • Back-office operators Type the password Mahadata who configure SSO on behalf of an enterprise tenant during onboarding. Configuration is done in the back-office on /clients/<id>/sso.

When a user opens the customer portal login page, the form displays the standard email + password + TOTP fields. When the user types an email, Mahadata automatically checks (after a short debounce) whether the email domain (the part after @) is bound to an active SSO configuration. If so, an additional button “Continue with <provider>” appears below the Login button, separated by an “or” divider. The password field remains visible.

Users can choose either path:

  • Type the password Mahadata → Login → email + password flow + (optional TOTP)
  • Click “Continue with <provider>” → redirected to the IdP → authentication via the methods implemented by the IdP (corporate password, MFA, smart card) → return to Mahadata, logged in

If the email domain not bound to an SSO configuration, the SSO button does not appear. Users only see the password path.

Both paths are designed side by side — there is no all-or-nothing toggle in v1. The password path always remains available as a fallback when the IdP is down or the admin’s IdP account is locked out.

ProtocolBest forWhat you need
SAML 2.0Most enterprise IdPs (Okta, Microsoft Entra ID, Auth0, Keycloak, OneLogin)IdP metadata URL, OR IdP Entity ID + SSO URL + signing certificate
OpenID Connect (OIDC)Google Workspace, Auth0, modern OIDC-based IdPsIdP discovery URL (.well-known/openid-configuration) + client_id + client_secret that you create in the IdP admin console

Both protocols deliver the same user experience. Choose the one natively supported by your IdP; if both are available, SAML is the more conservative choice because the IdP metadata already bundles the signing certificate and rotation is covered by the format itself.

Roles, JIT provisioning, and password fallback

Section titled “Roles, JIT provisioning, and password fallback”

Mahadata never copies passwords from your IdP. The only thing the IdP tells Mahadata is “this email is authenticated and belongs to your tenant.”

When a user logs in via SSO for the first time, Mahadata automatically creates a row users for them — this is called just-in-time (JIT) provisioning. Fields are populated from the SAML assertion or OIDC ID token:

  • email — required; the IdP must include it
  • name — optional, falls back to the local part of the email
  • client_account_id — stays fixed to your tenant
  • role — set to default role that you configure

Subsequent logins look up the existing user by email and update the name if it has changed. Role changes within Mahadata are not overwritten — promoting a user from Agens to Manajer in Settings → Team will persist across SSO logins.

Password access remains available. Even after SSO is configured for your domain:

  • Users can click “Use password” on the login form to fall back to email + password + TOTP for that session.
  • Superadmin Mahadata can always log in using a password as a fallback mechanism.

Domain verification (self-serve path only)

Section titled “Domain verification (self-serve path only)”

When you configure SSO from the portal, Mahadata requires you to to prove domain ownership that you claim. Without this, anyone could create an SSO configuration for gmail.com and harvest credentials. Verification is done via a DNS TXT record OR a file at a well-known HTTPS URL — choose whichever you can publish.

Operator-operated BO configuration not require domain verification (the operator implicitly attests on behalf of the tenant). The lookup that runs at login (/auth/sso/lookup) still requires domain_verified_at IS NOT NULL — so portal-configured SSO does not take effect until verification succeeds.

Setting up SSO from the portal (self-serve)

Section titled “Setting up SSO from the portal (self-serve)”

What you need:

  • A user account Mahadata in your tenant with the Settings → Manage SSO permission. The system “Admin” role has it by default.
  • Admin access to your IdP (Okta, Azure, Google, etc.) — you will register Mahadata as a a Service Provider or OAuth Application.
  • The ability to publish a DNS TXT record OR upload a file to your domain’s web root.
app.mahadata.io/settings/sso
SSO settings list — a table of configured providers with an Add button
SSO settings list — a table of configured providers with an Add button
  1. Open the SSO settings page

    In the portal, go to Settings → SSO. If you don’t see “SSO” in the left navigation, you don’t have that permission — ask your tenant admin to grant it via Settings → Roles.

  2. Click “Add SSO Provider”

    A wizard opens. Choose SAML or OIDC at the top.

    SAML form — paste your IdP metadata URL and click Parse to auto-populate the IdP details:

    OIDC form — paste your discovery URL and click Discover, then enter the client_id/secret issued by your IdP:

  3. Choose a protocol

    Select SAML or OIDC based on what your IdP supports best. If both are available, choose SAML.

  4. Fill in the IdP details

    For SAML, you can:

    • Metadata URL (easiest) — paste the IdP metadata URL (for example, https://acme.okta.com/app/<id>/sso/saml/metadata for Okta) and click Parse Metadata. The form will be filled in automatically:
      • IdP Entity ID — the globally unique identifier of the IdP (a URN-like string, not a URL you visit)
      • IdP SSO URL — where Mahadata redirects users for authentication
      • IdP X.509 Certificate — the IdP’s public signing certificate; Mahadata uses it to verify that the SAML assertion genuinely comes from your IdP
    • Manual entry — if your IdP does not expose a metadata URL, paste the Entity ID, SSO URL, and certificate manually. For OIDC:
    • Discovery URL (easiest) — paste the IdP URL .well-known/openid-configuration IdP (for example https://accounts.google.com/.well-known/openid-configuration) and click Discover. The form will be filled in automatically: issuer, authorization endpoint, token endpoint, and JWKS URI.
    • Then provide:
      • Client ID — issued by the IdP when you register Mahadata as an OAuth application
      • Client Secret — issued together with the Client ID. Treat it like a password. Mahadata encrypts it at rest with AES-256-GCM and never returns it in API responses.
  5. Identity mapping

    • Display Name — what users see on the portal “Continue with X” button. Example: Lanjutkan dengan Acme Okta, Masuk dengan Google Workspace. Make it easily recognizable to your users.
    • Domain Mapping — the email domain (without @) that triggers SSO. If you set up acme.com, then alice@acme.com typed on the login page will see your SSO button. Subdomains do not match unless you add them as a separate configuration.
    • Default Role — the role Mahadata assigned to SSO users the first time from this domain. Choose the strictest role that still allows them to do their job.
    • Enable JIT Provisioning — keep it enabled. If turned off, users can only log in via SSO if an account Mahadata already exists for their email; the platform will reject first-time SSO logins.
  6. Save

    The detail page opens. You will see:

    • SP-side URL that needs to be pasted into the Service Provider configuration in your IdP:
      • SP Entity ID — https://<api-host-anda>/auth/sso/<config-id>/saml. Paste it into Okta’s “Audience URI” field (or Azure’s “Identifier”).
      • ACS URL — https://<api-host-anda>/auth/saml/acs?config_id=<config-id>. Paste it into your Okta “Single sign on URL” / Azure “Reply URL”.
      • SP Metadata URL — a link that the IdP can fetch directly to import everything at once.
      • OIDC Redirect URI — OIDC only — https://<api-host-anda>/auth/oidc/callback?config_id=<config-id>. Paste it into the “Authorized redirect URIs” of the IdP’s OAuth application. Copy these URLs into the Service Provider configuration / OAuth application screen in your IdP now. Most IdPs will reject login attempts until they recognize Mahadata as a registered SP / OAuth client.
  7. Verify your domain

    After saving, the detail page opens with the IdP details on the left and the “Verify your domain” card at the top. SSO login only works on verified domains.

    Click “Get TXT Record” (or switch to HTTP if you cannot add a DNS record). The card will display the exact record name and value to copy:

    TXT method (recommended):

    • Type: TXT
    • Name: _mahadata.<domain-anda> (e.g. _mahadata.acme.com)
    • Value: mahadata-domain-verify=<token-32-karakter> Add this TXT record at your DNS provider (Cloudflare, Route53, GoDaddy, etc.). DNS propagation can take a few minutes. Once added, click Verify.

    If the lookup succeeds, the card turns into a green “Verified” badge and SSO is active for users on this domain.

    HTTP method (alternative):

    • Mahadata expects a file at https://<domain-anda>/.well-known/mahadata-domain-verify.txt
    • The file content must be exactly mahadata-domain-verify=<token-32-karakter>
    • HTTPS is required (Mahadata follows up to 3 redirects, all to HTTPS)
    • Click Verify once the file is reachable
  8. Test connection

    The detail page has a Test connection button. Click it. Mahadata fetches the IdP metadata (SAML) or runs OIDC discovery against the configured URL — proving that the IdP is reachable and the certificate/keys can be parsed. If it fails, fix it upstream (URL typo, IdP unreachable, etc.) before testing the user flow.

  9. Test as a real user

    • Log out of Mahadatatab.
    • Open the login page.
    • Type an email matching the domain you configured (for example alice@acme.com).
    • After a ~400ms debounce, an additional button labeled “Continue with <Display Name>” appears below the Sign In button. The password field remains visible — this is intentional.
    • Click “Continue with <Display Name>”. You will be redirected to the IdP. Authenticate. You should return to the inbox Mahadata, logged in as Alice.
    • Open Settings → Team and confirm the user alice@acme.com exists with the role you set as the default.

Setting up SSO from the back-office (operator)

Section titled “Setting up SSO from the back-office (operator)”

This path is for staff Mahadata staff configuring SSO on behalf of an enterprise tenant — typically during onboarding. The flow is the same as self-service except:

  • Configuration is done in the back-office at /clients/<client-id>/sso, not in the customer portal.
  • <ClientSelector> is not required — you are already on a specific client’s detail page; client_account_id is determined by the URL.
  • Domain verification skipped — the operator’s action implicitly declares ownership. Login hint lookup still requires domain_verified_at IS NOT NULL, so the operator’s storage automatically marks the row as verified.
  • All other fields (Entity ID, default roles, etc.) work identically.
FieldRequired?Description
ProtocolYessaml or oidc. Cannot be changed after saving.
Display NameYesPlain text displayed on the portal login button. Make it easily recognizable to users.
Domain MappingRecommendedEmail domain (without @) that triggers SSO on the login page. Without this, the configuration exists but no users will access the SSO path.
Default RoleRecommendedRole Mahadata role assigned to SSO users on first login. Falls back to agens if not set.
JIT ProvisioningEnabled by defaultIf enabled, the first SSO login automatically creates a row usersrow. If not active, the user must already exist in Mahadata for SSO to succeed.
ActiveEnabled by defaultIf disabled, the configuration exists but is not visible to login discovery. Use to temporarily disable without deleting.
FieldRequired?Description
IdP Metadata URLOne of (URL or manual fields)URL of the XML document published by the IdP. The fastest setup path — click “Parse Metadata” to auto-fill the rest.
IdP Entity IDIf without a Metadata URLGlobally unique identifier of the IdP. Similar to https://acme.okta.com/saml/idp/<id>. This is an identifier, not a URL that is visited.
IdP SSO URLIf without a Metadata URLWhere Mahadata redirects users for authentication.
IdP X.509 CertificateIf without a Metadata URLThe IdP’s public signing certificate (PEM Base64). Used Mahadata to verify every incoming SAML assertion.
SAML Signature AlgorithmDefault rsa-sha256Cryptographic algorithm. Do not change unless your IdP requires it (it almost certainly accepts rsa-sha256).
Mandatory Assertion VerificationEnabled by defaultIf enabled, Mahadata rejects assertions that are not cryptographically signed. Always keep it enabled in production.
FieldRequired?Description
Discovery URLRecommendedURL .well-known/openid-configuration IdP. Click “Discover” to auto-fill the issuer / authorization / token / JWKS endpoints.
IssuerAuto-filledClaim iss expected Mahadata in your IdP’s ID token.
Authorization EndpointAuto-filledWhere Mahadata redirects users for authentication.
Token EndpointAuto-filledWhere Mahadata exchanges the auth code for a token.
JWKS URIAuto-filledWhere Mahadata fetches the IdP’s public keys to verify the ID token signature.
Client IDYesCreated by the IdP when you register Mahadata as an OAuth application.
Client SecretYesIssued together with the Client ID. Treated like a password — encrypted at rest, never returned in API responses. Once saved, the field displays ••••••••. Leave it blank when editing to retain the existing value.
ScopesDefault openid email profileOAuth scopes requested Mahadata. The email scope is required (Mahadata cannot perform JIT provisioning without it).

The “Continue with X” button does not appear after typing the email

Section titled “The “Continue with X” button does not appear after typing the email”

Three possible causes, in order:

  1. Domain is not verified. The search endpoint requires domain_verified_at IS NOT NULL. Open the portal SSO settings, find the configuration, check the verification card.
  2. Domain typo. The domain in the email must exactly match the domain_mapping configuration (case-insensitive). bob@acme.com does not equal bob@acme-corp.com.
  3. Configuration is disabled. Toggle Aktif off — turn it back on.

”Test connection” succeeds but login fails

Section titled “”Test connection” succeeds but login fails”
  1. The IdP does not recognize Mahadata. You need to register Mahadata in the IdP admin console using the SP Entity ID + ACS URL (SAML) or Redirect URI (OIDC).
  2. IdP certificate is wrong. Metadata may have been sent with one certificate but the IdP signs with another. Re-fetch the IdP metadata via “Test connection”.
  3. SAML response signature failed. Check Kesalahan Terakhir on the configuration detail page.
  4. OIDC token verification failed. Check Kesalahan Terakhir. Common causes: clock skew on the IdP server, rotated JWKS keys.

For TXT:

  • DNS propagation. Wait up to one hour, then try again.
  • Wrong record name. Must be _mahadata.<domain-anda> — the underscore prefix is required.
  • Wrong record value. Must be exactly mahadata-domain-verify=<token>. Do not add quotation marks.
  • Verify with dig TXT _mahadata.<domain-anda>.

For HTTP:

  • HTTPS is required. HTTP-only domains will not be verified.
  • The path must be exact: /.well-known/mahadata-domain-verify.txt.
  • The content must exact mahadata-domain-verify=<token>.
  • The status must be 200.

The IdP certificate has been rotated, login fails

Section titled “The IdP certificate has been rotated, login fails”

Open the SSO configuration detail page, click Test connection. This re-fetches the IdP metadata and updates the cached certificate.

No. SSO is per-tenant and optional. Most small/medium tenants use email + password + TOTP and never configure SSO.

Yes — multiple configurations per tenant are supported, one per domain. If your organization has acme.com and acme.co.uk pointed to different IdPs, create two configurations. A single domain can only be bound to one active + verified configuration at a time.

Not yet in v1. Every JIT-provisioned user gets default_role_id the same. Promoting a user to another role is a manual action in Settings → Team after the first login.

What happens to users Mahadata who already exist when SSO is enabled?

Section titled “What happens to users Mahadata who already exist when SSO is enabled?”

Nothing changes for them. They keep their password Mahadata. Once SSO is configured, when they type their email on the login page they will see an SSO button — they can click it (a one-time link to the existing user record based on email) or click “Use password”.

How do I revoke access for a user who leaves the company?

Section titled “How do I revoke access for a user who leaves the company?”
  1. In the IdP — deactivate their account in Okta/Azure/etc. They lose SSO access immediately. Their Mahadata account still exists, but if they don’t have a password Mahadata (common for SSO-only users), they cannot log in.
  2. In Mahadata — deactivate or delete the users row in Settings → Team. This is the right step if you also want to prevent fallback password access.

Yes — every successful SSO login publishes the auth.sso.login event, and every failed attempt publishes auth.sso.failed. The audit consumer writes these to the standard audit log.