# xstring-tech/xst-authentication-api architecture

> Architecture diagram of the GitHub repository xstring-tech/xst-authentication-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xstring-tech/xst-authentication-api
- Repository: https://github.com/xstring-tech/xst-authentication-api

## Overview

This repository is a Node.js example CCS that delegates passwordless sign-in to xString Tech’s hosted authentication service. A user starts sign-in at the CCS, which submits an Authentication Notice of Intent and redirects the browser to hosted authentication. On return, the CCS exchanges the code, verifies the ID Token, establishes a signed session, and serves a protected portal; logout clears that session. The README also describes compatible authenticator apps and a language-agnostic API. The PHP integration is present in the tree, but its behavior is not represented because its source was not sampled.

Main entry points: [`server.js`](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js) (Sign-in Initiation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ccs["CCS Web Application"]
  node_landing["CCS Landing Page<br/>[server.js]"]
  node_auth_start["Sign-in Initiation<br/>[server.js]"]
  node_code_exchange["Code Exchange<br/>[server.js]"]
  node_token_validation["ID Token Verification<br/>[server.js]"]
end

subgraph group_hosted["Hosted Authentication"]
  node_api["SaaS Authentication API"]
  node_hosted_auth["Hosted Authentication"]
  node_jwks["JWKS Endpoint"]
end

subgraph group_session["Session and Portal"]
  node_session_cookie["Signed Session Cookie<br/>[server.js]"]
  node_portal["Protected Portal<br/>[server.js]"]
  node_logout["Logout Handling<br/>[server.js]"]
  node_logout_page["Logout Confirmation<br/>[server.js]"]
end

node_user(("End User"))
node_browser(("User Browser"))
node_authenticator["Authenticator App"]

node_user -->|"uses"| node_browser
node_browser -->|"opens"| node_landing
node_landing -->|"starts sign-in"| node_auth_start
node_auth_start -->|"submits ANoI"| node_api
node_auth_start -->|"redirects browser"| node_hosted_auth
node_browser -->|"completes authentication"| node_hosted_auth
node_user -->|"approves request"| node_authenticator
node_hosted_auth -->|"returns code and state"| node_browser
node_browser -->|"returns code"| node_code_exchange
node_code_exchange -->|"exchanges code"| node_api
node_code_exchange -->|"passes ID Token"| node_token_validation
node_token_validation -->|"fetches public keys"| node_jwks
node_token_validation -->|"establishes session"| node_session_cookie
node_browser -->|"requests portal"| node_portal
node_portal -->|"checks session"| node_session_cookie
node_browser -->|"submits logout"| node_logout
node_logout -->|"clears cookie"| node_session_cookie
node_logout -->|"redirects to"| node_logout_page
node_browser -->|"views confirmation"| node_logout_page

click node_landing "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"
click node_auth_start "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"
click node_code_exchange "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"
click node_token_validation "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"
click node_session_cookie "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"
click node_portal "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"
click node_logout "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"
click node_logout_page "https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_landing,node_auth_start,node_code_exchange,node_token_validation,node_user,node_browser toneBlue
class node_api,node_hosted_auth,node_jwks toneAmber
class node_session_cookie,node_portal,node_logout,node_logout_page toneMint
class node_authenticator toneIndigo
```

## Components

### CCS Web Application

- [CCS Landing Page](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`
- [Sign-in Initiation](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`
- [Code Exchange](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`
- [ID Token Verification](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`

### Hosted Authentication

- **SaaS Authentication API**
- **Hosted Authentication**
- **JWKS Endpoint**

### Session and Portal

- [Signed Session Cookie](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`
- [Protected Portal](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`
- [Logout Handling](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`
- [Logout Confirmation](https://github.com/xstring-tech/xst-authentication-api/blob/main/server.js): `server.js`

### Other components

- **End User**
- **User Browser**
- **Authenticator App**

## Connections

- End User → User Browser: uses (evidence: `README.md`)
- User Browser → CCS Landing Page: opens (evidence: `README.md`)
- CCS Landing Page → Sign-in Initiation: starts sign-in (evidence: `README.md`)
- Sign-in Initiation → SaaS Authentication API: submits ANoI (evidence: `server.js`)
- Sign-in Initiation → Hosted Authentication: redirects browser (evidence: `server.js`)
- User Browser → Hosted Authentication: completes authentication (evidence: `README.md`)
- End User → Authenticator App: approves request (evidence: `README.md`)
- Hosted Authentication → User Browser: returns code and state (evidence: `README.md`)
- User Browser → Code Exchange: returns code (evidence: `README.md`)
- Code Exchange → SaaS Authentication API: exchanges code (evidence: `server.js`)
- Code Exchange → ID Token Verification: passes ID Token (evidence: `README.md`)
- ID Token Verification → JWKS Endpoint: fetches public keys (evidence: `server.js`)
- ID Token Verification → Signed Session Cookie: establishes session (evidence: `README.md`)
- User Browser → Protected Portal: requests portal (evidence: `server.js`)
- Protected Portal → Signed Session Cookie: checks session (evidence: `server.js`)
- User Browser → Logout Handling: submits logout (evidence: `server.js`)
- Logout Handling → Signed Session Cookie: clears cookie (evidence: `server.js`)
- Logout Handling → Logout Confirmation: redirects to (evidence: `server.js`)
- User Browser → Logout Confirmation: views confirmation (evidence: `server.js`)
