# hkamel/sonar-auth-aad architecture

> Architecture diagram of the GitHub repository hkamel/sonar-auth-aad, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hkamel/sonar-auth-aad
- Repository: https://github.com/hkamel/sonar-auth-aad

## Overview

##### Main Components
- SonarQube Server – the host system that will load this plugin.
- AAD Authentication Plugin – the core module that interfaces with SonarQube for authentication.
- AAD Integration Module – the internal components within the plugin that interact with Microsoft Azure services. This includes:
- AadIdentityProvider (which likely acts as an entry point for authentication requests)
- AadTokenHelper (handles token manipulation and validation)
- AadUserInfo (processes and structures information about authenticated users)
- AadSettings (manages configuration or initialization settings for AAD integration)
- AuthAadPlugin (ties everything together as the plugin interface for SonarQube)
- External Service – Microsoft Azure Active Directory, representing the external authentication provider.
- Supporting Resources – configuration files and localization resources (e.g., the properties file for localization in src/main/resources/org/sonar/l10n/authaad.properties) that support internationalization or regional configuration.

##### Relationships and Data Flow
- The SonarQube Server loads the plug-in (AuthAadPlugin) as part of its authentication mechanism.
- When a user attempts to authenticate, SonarQube delegates the process to the AAD Authentication Plugin.
- Within the plugin, AadIdentityProvider and AadTokenHelper coordinate to validate and process the user’s credentials.
- AadUserInfo retrieves or builds the user details and passes information back to SonarQube after token verification.
- The plugin also references configuration settings (AadSettings) to determine connection parameters (client ID, tenant information, etc.) needed to interact with the external Azure AD service.
- Data flow should clearly illustrate the communication between SonarQube, the plugin internal classes, and the external Azure AD service.

##### Architectural Patterns and Technologies
- Java/Maven-based application structure where source and test code separation emphasizes professional modular design.
- Standard plugin pattern for extending SonarQube capabilities.
- The integration with Microsoft Azure Active Directory hinges on standard authentication protocols (likely OAuth2 or OpenID Connect).
- Use of configuration and resource files to externalize settings and provide localization support.

## Diagram (Mermaid)

```mermaid
flowchart TD
    sonar["SonarQube Server"]:::external
    azure["Microsoft Azure AD"]:::external
    localizationResource["Localization/Configuration Resources"]:::resource

    subgraph "AAD Authentication Plugin"
        pluginPkg["AAD Authentication Plugin"]:::plugin
        authAadPlugin["AuthAadPlugin – SonarQube Plugin Interface"]:::plugin
        aadIdentityProvider["AadIdentityProvider – Entry Point for Authentication"]:::plugin
        aadTokenHelper["AadTokenHelper – Token Manipulation"]:::plugin
        aadUserInfo["AadUserInfo – Builds User Details"]:::plugin
        aadSettings["AadSettings – Configuration Manager"]:::plugin
    end

    sonar -->|"Authentication_Request"| pluginPkg
    pluginPkg -->|"Initializes"| authAadPlugin
    authAadPlugin -->|"Load_Configuration"| aadSettings
    authAadPlugin -->|"Delegates"| aadIdentityProvider
    aadIdentityProvider -->|"Token_Processing"| aadTokenHelper
    aadTokenHelper -->|"Token_Validation_Request"| azure
    azure -->|"Validation_Response"| aadTokenHelper
    aadTokenHelper -->|"Process_User_Info"| aadUserInfo
    aadUserInfo -->|"Authenticated_User_Details"| sonar
    authAadPlugin -->|"Read_Localization"| localizationResource

    click pluginPkg "https://github.com/hkamel/sonar-auth-aad/tree/master/src/main/java/org/almrangers/auth/aad"
    click authAadPlugin "https://github.com/hkamel/sonar-auth-aad/blob/master/src/main/java/org/almrangers/auth/aad/AuthAadPlugin.java"
    click aadIdentityProvider "https://github.com/hkamel/sonar-auth-aad/blob/master/src/main/java/org/almrangers/auth/aad/AadIdentityProvider.java"
    click aadTokenHelper "https://github.com/hkamel/sonar-auth-aad/blob/master/src/main/java/org/almrangers/auth/aad/AadTokenHelper.java"
    click aadUserInfo "https://github.com/hkamel/sonar-auth-aad/blob/master/src/main/java/org/almrangers/auth/aad/AadUserInfo.java"
    click aadSettings "https://github.com/hkamel/sonar-auth-aad/blob/master/src/main/java/org/almrangers/auth/aad/AadSettings.java"
    click localizationResource "https://github.com/hkamel/sonar-auth-aad/blob/master/src/main/resources/org/sonar/l10n/authaad.properties"

    classDef plugin fill:#bbf,stroke:#333,stroke-width:2px;
    classDef external fill:#f96,stroke:#333,stroke-width:2px;
    classDef resource fill:#cfc,stroke:#333,stroke-width:2px;
```
