chartletv0.23.0

← All examples

Sign-in: the token exchange

The sign-in sequence with the identity provider emphasized and the messages between the web backend and the provider drawn in the accent, labels in bold. The legend names the three kinds of message, call, reply and asynchronous, and the emphasis.

Sign-in: the token exchange

examples/sign-in-focus.json
{
  "schemaVersion": 1,
  "type": "sequence",
  "title": "Sign-in: the token exchange",
  "source": "Illustrative reference architecture",
  "width": 900,
  "height": 900,
  "sequence": {
    "participants": [
      {
        "id": "browser",
        "label": "Browser",
        "kind": "actor"
      },
      {
        "id": "bff",
        "label": "Web / BFF",
        "sublabel": "SvelteKit"
      },
      {
        "id": "idp",
        "label": "Keycloak",
        "sublabel": "OIDC"
      },
      {
        "id": "api",
        "label": "Domain API",
        "sublabel": "Rust"
      },
      {
        "id": "db",
        "label": "Postgres",
        "sublabel": "RLS",
        "kind": "database"
      }
    ],
    "messages": [
      {
        "from": "browser",
        "to": "bff",
        "label": "GET /grades"
      },
      {
        "from": "bff",
        "to": "browser",
        "label": "Redirect, PKCE",
        "kind": "reply"
      },
      {
        "from": "browser",
        "to": "idp",
        "label": "Sign in, 2FA"
      },
      {
        "from": "idp",
        "to": "browser",
        "label": "Code",
        "kind": "reply"
      },
      {
        "from": "browser",
        "to": "bff",
        "label": "Callback with code"
      },
      {
        "from": "bff",
        "to": "idp",
        "label": "Exchange code"
      },
      {
        "from": "idp",
        "to": "bff",
        "label": "Tokens",
        "kind": "reply"
      },
      {
        "from": "bff",
        "to": "bff",
        "label": "Create session"
      },
      {
        "from": "bff",
        "to": "api",
        "label": "Load grades"
      },
      {
        "from": "api",
        "to": "db",
        "label": "Set tenant, SELECT"
      },
      {
        "from": "db",
        "to": "api",
        "label": "own school only",
        "kind": "reply"
      },
      {
        "from": "api",
        "to": "bff",
        "label": "Grades",
        "kind": "reply"
      },
      {
        "from": "bff",
        "to": "browser",
        "label": "Page, session cookie",
        "kind": "reply"
      },
      {
        "from": "idp",
        "to": "bff",
        "label": "Backchannel logout",
        "kind": "async"
      },
      {
        "from": "bff",
        "to": "bff",
        "label": "End sessions"
      }
    ],
    "fragments": [
      {
        "kind": "opt",
        "label": "central sign-out",
        "from": 13,
        "to": 14
      }
    ],
    "numbered": true
  },
  "mobile": {
    "width": 400,
    "height": 920
  },
  "emphasis": {
    "nodes": [
      "idp"
    ],
    "path": [
      "bff",
      "idp"
    ]
  },
  "legend": "auto"
}
Focus
Sign-in: the token exchange
Sign-in: the token exchangeSequence diagram with 5 participants: Browser (actor), Web / BFF, Keycloak, Domain API and Postgres (database). 15 messages, in order: 1. Browser to Web / BFF: GET /grades. 2. Web / BFF to Browser: Redirect, PKCE (reply). 3. Browser to Keycloak: Sign in, 2FA. 4. Keycloak to Browser: Code (reply). 5. Browser to Web / BFF: Callback with code. 6. Web / BFF to Keycloak: Exchange code. 7. Keycloak to Web / BFF: Tokens (reply). 8. Web / BFF to itself: Create session. 9. Web / BFF to Domain API: Load grades. 10. Domain API to Postgres: Set tenant, SELECT. 11. Postgres to Domain API: own school only (reply). 12. Domain API to Web / BFF: Grades (reply). 13. Web / BFF to Browser: Page, session cookie (reply). 14. Keycloak to Web / BFF: Backchannel logout (asynchronous). 15. Web / BFF to itself: End sessions. Fragment opt "central sign-out" spans messages 14–15. Emphasized: Keycloak. Emphasized path: Web / BFF → Keycloak. Legend: call, reply, asynchronous, emphasized, emphasized path.opt[central sign-out]1. Browser → Web / BFF: GET /gradesGET /grades12. Web / BFF → Browser: Redirect, PKCERedirect, PKCE23. Browser → Keycloak: Sign in, 2FASign in, 2FA34. Keycloak → Browser: CodeCode45. Browser → Web / BFF: Callback with codeCallback with code56. Web / BFF → Keycloak: Exchange codeExchange code67. Keycloak → Web / BFF: TokensTokens78. Web / BFF → Web / BFF: Create sessionCreate session89. Web / BFF → Domain API: Load gradesLoad grades910. Domain API → Postgres: Set tenant, SELECTSet tenant, SELECT1011. Postgres → Domain API: own school onlyown school only1112. Domain API → Web / BFF: GradesGrades1213. Web / BFF → Browser: Page, session cookiePage, session cookie1314. Keycloak → Web / BFF: Backchannel logoutBackchannel logout1415. Web / BFF → Web / BFF: End sessionsEnd sessions15BrowserBrowserWeb / BFF – SvelteKitWeb / BFFSvelteKitKeycloak – OIDCKeycloakOIDCDomain API – RustDomain APIRustPostgres – RLSPostgresRLSCallReplyAsynchronousEmphasizedEmphasized path
Sign-in: the token exchangeSequence diagram with 5 participants: Browser (actor), Web / BFF, Keycloak, Domain API and Postgres (database). 15 messages, in order: 1. Browser to Web / BFF: GET /grades. 2. Web / BFF to Browser: Redirect, PKCE (reply). 3. Browser to Keycloak: Sign in, 2FA. 4. Keycloak to Browser: Code (reply). 5. Browser to Web / BFF: Callback with code. 6. Web / BFF to Keycloak: Exchange code. 7. Keycloak to Web / BFF: Tokens (reply). 8. Web / BFF to itself: Create session. 9. Web / BFF to Domain API: Load grades. 10. Domain API to Postgres: Set tenant, SELECT. 11. Postgres to Domain API: own school only (reply). 12. Domain API to Web / BFF: Grades (reply). 13. Web / BFF to Browser: Page, session cookie (reply). 14. Keycloak to Web / BFF: Backchannel logout (asynchronous). 15. Web / BFF to itself: End sessions. Fragment opt "central sign-out" spans messages 14–15. Emphasized: Keycloak. Emphasized path: Web / BFF → Keycloak. Legend: call, reply, asynchronous, emphasized, emphasized path.opt[central sign-out]1. Browser → Web / BFF: GET /gradesGET /grades12. Web / BFF → Browser: Redirect, PKCERedirect, PKCE23. Browser → Keycloak: Sign in, 2FASign in, 2FA34. Keycloak → Browser: CodeCode45. Browser → Web / BFF: Callback with codeCallback with code56. Web / BFF → Keycloak: Exchange codeExchange code67. Keycloak → Web / BFF: TokensTokens78. Web / BFF → Web / BFF: Create sessionCreate session89. Web / BFF → Domain API: Load gradesLoad grades910. Domain API → Postgres: Set tenant, SELECTSet tenant, SELECT1011. Postgres → Domain API: own school onlyown school only1112. Domain API → Web / BFF: GradesGrades1213. Web / BFF → Browser: Page, session cookiePage, session cookie1314. Keycloak → Web / BFF: Backchannel logoutBackchannel logout1415. Web / BFF → Web / BFF: End sessionsEnd sessions15BrowserBrowserWeb / BFF – SvelteKitWeb /BFFSvelteKitKeycloak – OIDCKeycloakOIDCDomain API – RustDomainAPIRustPostgres – RLSPostgresRLSCallReplyAsynchronousEmphasizedEmphasized path

Source: Illustrative reference architecture

Show chart data
Data for Sign-in: the token exchange
No.FromToMessageKindFragmentEmphasis
1BrowserWeb / BFFGET /gradescall
2Web / BFFBrowserRedirect, PKCEreply
3BrowserKeycloakSign in, 2FAcall
4KeycloakBrowserCodereply
5BrowserWeb / BFFCallback with codecall
6Web / BFFKeycloakExchange codecallon emphasized path
7KeycloakWeb / BFFTokensreplyon emphasized path
8Web / BFFWeb / BFFCreate sessioncall
9Web / BFFDomain APILoad gradescall
10Domain APIPostgresSet tenant, SELECTcall
11PostgresDomain APIown school onlyreply
12Domain APIWeb / BFFGradesreply
13Web / BFFBrowserPage, session cookiereply
14KeycloakWeb / BFFBackchannel logoutasynchronousopt [central sign-out]on emphasized path
15Web / BFFWeb / BFFEnd sessionscallopt [central sign-out]
  • Sequence diagram with emphasis and a legend
  • Point at one exchange between two systems