# sample/pritunl-keycloak-user-check architecture

> Architecture diagram of the GitHub repository sample/pritunl-keycloak-user-check, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sample/pritunl-keycloak-user-check
- Repository: https://github.com/sample/pritunl-keycloak-user-check

## Overview

##### Main Components
- Pritunl VPN Server – Represents the core VPN service that is extended through plugins.
- Plugin (keycloak-user-check.py) – The Python script responsible for intercepting VPN connection attempts and communicating with Keycloak.
- Keycloak Server – The external authentication service that provides user status and credential verification.
- Configuration/Integration Layer – Although not a separate service, visually emphasize the configuration parameters (KEYCLOAK_URL, REALM, CLIENT_ID, CLIENT_SECRET, etc.) that tie together the plugin’s interactions with Keycloak.

##### Their Relationships and Interactions
- Configuration parameters between the plugin and Keycloak to show how the integration is parameterized.

##### Architectural Patterns and Design Principles
- Middleware/Plugin Pattern – The plugin acts as an interceptor, managing authentication flow between the VPN and the external IdP.
- Dependency on External Services – Clearly note that Keycloak’s availability is crucial for VPN access, indicating a tight coupling for authentication purposes.
- Real-time Data Flow – Emphasize the fact that user status checking happens in real time during connection attempts.

##### Incorporate Relevant Technologies and Libraries
- Python Script: keycloak-user-check.py is implemented in Python.
- Keycloak: Uses OpenID Connect for authentication.
- Pritunl: The VPN server that supports plugins for extended authentication and security.

##### Final Points
- Avoid over-cluttering—focus on clearly separating the three key components and their interactions.

This approach provides a comprehensive visual aid for understanding and maintaining the integration between Pritunl and Keycloak using the keycloak-user-check plugin.

## Diagram (Mermaid)

```mermaid
flowchart TD
    PVPN["Pritunl VPN Server\n(Handles VPN connections)"]:::external
    Plugin["Plugin (keycloak-user-check.py)\nChecks user status in Keycloak"]:::plugin
    Keycloak["Keycloak Server\n(Authentication and User Management)"]:::external
    Config["Configuration Parameters\n(KEYCLOAK_URL, REALM, CLIENT_ID, CLIENT_SECRET)"]:::config

    PVPN -->|"calls"| Plugin
    Plugin -->|"API_call"| Keycloak
    Keycloak -->|"response"| Plugin
    Config ---|"configures"| Plugin
    Config ---|"configures"| Keycloak

    click PVPN "https://github.com/sample/pritunl-keycloak-user-check/blob/main/PRITUNL-SAML-KEYCLOAK-INTEGRATION.md"
    click Plugin "https://github.com/sample/pritunl-keycloak-user-check/blob/main/keycloak-user-check.py"
    click Keycloak "https://github.com/sample/pritunl-keycloak-user-check/blob/main/PRITUNL-SAML-KEYCLOAK-INTEGRATION.md"
    click Config "https://github.com/sample/pritunl-keycloak-user-check/blob/main/PRITUNL-SAML-KEYCLOAK-INTEGRATION.md"

classDef external fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
classDef plugin fill:#ccffcc,stroke:#009900,stroke-width:2px;
classDef config fill:#cce5ff,stroke:#0047b3,stroke-dasharray: 5 5,stroke-width:2px;
```
