DaaS / Products / Authenticated Embedded Documentation Portal

Authenticated Embedded Documentation Portal

A SaaS team publishes product documentation on GitBook, embeds it into their customer portal, and gates access behind IDaaS-configured authentication (social login, 2FA) so only authenticated users can view the embedded docs.

Products involved

Scenario

When a SaaS platform needs to deliver contextual, version-controlled documentation directly inside its customer dashboard while enforcing strict identity verification. This workflow combines GitBook’s publishing and embedding capabilities with IDaaS to ensure only verified users (via social login + 2FA) can access private documentation spaces.

Integration steps

  1. Configure IDaaS Authentication: In the IDaaS console, create an OIDC application. Enable social providers (Google/WeChat) under Identity Providers and enforce 2FA via Security Policies > Multi-Factor Authentication. Record client_id, client_secret, and issuer URL.
  2. Set GitBook Access Control: In GitBook, navigate to Space Settings > Access Control. Set visibility to Private and enable JWT Authentication. Generate an HS256 signing secret or upload a JWKS public key.
  3. Implement Token Exchange: In your SaaS backend, handle the IDaaS OIDC callback. Exchange the authorization code for an IDaaS access token via POST https://<tenant>.idaas.aliyuncs.com/oauth2/token, then mint a GitBook-compatible JWT:
  4. ``bash jwt encode --alg HS256 --secret $GITBOOK_HS256_SECRET \ --payload '{"sub":"user_123","email":"[email protected]","exp":1735689600}' ``

  5. Initialize Embed SDK: Install @gitbook/embed and configure it with the private space URL and auth payload:
  6. ``javascript import { GitBookEmbed } from '@gitbook/embed'; const embed = new GitBookEmbed({ url: 'https://docs.yourdomain.com', auth: { type: 'jwt', token: generatedToken } }); ``

  7. Mount to Portal DOM: Render the embed container and attach the SDK:
  8. ``html <div id="gitbook-docs" style="height:80vh;width:100%"></div> <script>embed.mount('#gitbook-docs');</script> ``

  9. Validate & Test: Trigger social login + 2FA in the portal, verify the JWT is injected into the iframe postMessage, and confirm GitBook serves content without 401/403 errors.

Architecture

User initiates login in the SaaS portal → IDaaS orchestrates social auth + 2FA, returning an OIDC session → SaaS backend validates IDaaS claims and mints a GitBook-scoped JWT → Frontend passes the JWT to @gitbook/embed → GitBook validates the signature against the configured secret/JWKS and streams private documentation. IDaaS owns identity lifecycle; GitBook owns content delivery and access validation.

Prerequisites

Common pitfalls

Typical questions

FAQ

Q: How do I embed GitBook documentation behind authentication? A: You can protect an embedded documentation portal by combining GitBook Publish, GitBook Embed, and IDaaS authentication configuration. This setup lets you embed your GitBook site into a customer portal and gate access behind IDaaS methods like social login or two-factor authentication. As a result, only authenticated users can view the embedded content.