# azure/login architecture

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

- Interactive diagram: https://gitdiagram.com/azure/login
- Repository: https://github.com/azure/login

## Overview

##### Project type and purpose
- This is an open-source GitHub Action named “Azure Login Action.”
- It provides a Node.js/TypeScript implementation to authenticate a GitHub Actions workflow against Azure using CLI or PowerShell under various authentication mechanisms (OIDC, service principal secret, managed identity).

##### File structure
- action.yml: action metadata (inputs, outputs, pre/main/post hooks).
- src/
- main.ts           – entry point; orchestrates login + cleanup
- cleanup.ts        – implements pre/main and post cleanup steps
- common/           – LoginConfig.ts (input parsing), Utils.ts (shared helpers)
- Cli/              – AzureCliLogin.ts (encapsulates `az login` logic)
- PowerShell/       –
– AzPSLogin.ts      (PowerShell login orchestration)
– AzPSScriptBuilder.ts (generates PS scripts for login)
– AzPSUtils.ts      (PowerShell environment helpers)
- __tests__/           – Jest unit tests for config and PowerShell modules
- .github/workflows/  – CI pipelines (integration tests, canary, code scanning)
- package.json, tsconfig.json, jest.config.js, etc. for build/test

##### README for additional insights
- Describes all supported inputs (client-id, tenant-id, creds, auth-type, environment flags).
- Details usage scenarios (OIDC, SP secret, system/user-assigned managed identity).
- Explains cleanup toggles via environment variables for pre and post steps.
- References external services: GitHub OIDC token endpoint, Azure AD, Azure CLI, Azure PowerShell.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global entities
    Runner["GitHub Actions Runner"]:::external
    actionYml["action.yml"]:::internal
    main["main.ts\n(Node.js Action)"]:::internal

    %% Input sources
    inputs["Env Vars & Secrets"]:::internal
    githubOIDC["GitHub OIDC\nProvider"]:::external

    %% Internal modules
    subgraph "Core Modules"
        loginConfig["LoginConfig"]:::internal
        utils["Utils"]:::internal
        preCleanup["Pre-Cleanup"]:::hooks
        postCleanup["Post-Cleanup"]:::hooks
        subgraph "Auth Strategies"
            cli["AzureCliLogin"]:::internal
            psLogin["AzPSLogin"]:::internal
            psBuilder["AzPSScriptBuilder"]:::internal
            psUtils["AzPSUtils"]:::internal
        end
    end

    %% External services
    azureAD["Azure AD / MI Endpoint"]:::external
    azCLI["Azure CLI Binary"]:::external
    azPS["Azure PowerShell Module"]:::external

    %% CI pipelines
    CI["CI Pipelines\n(.github/workflows/)"]:::external

    %% Tests
    subgraph "Unit Tests"
        lcTest["LoginConfig Tests"]:::internal
        psLoginTest["AzPSLogin Tests"]:::internal
        psBuilderTest["AzPSScriptBuilder Tests"]:::internal
    end

    %% Connections
    Runner --> actionYml
    actionYml --> main
    inputs --> loginConfig
    githubOIDC --> loginConfig
    loginConfig --> utils
    main --> loginConfig
    main --> preCleanup
    preCleanup --> main
    main --> cli
    main --> psLogin
    cli --> azCLI
    azCLI --> azureAD
    psLogin --> psBuilder
    psLogin --> psUtils
    psLogin --> azPS
    azPS --> azureAD
    main --> postCleanup

    CI --> lcTest
    CI --> psLoginTest
    CI --> psBuilderTest
    CI --> actionYml
    CI --> main
    CI --> preCleanup
    CI --> loginConfig
    CI --> cli
    CI --> psLogin

    %% Click Events
    click actionYml "https://github.com/azure/login/blob/master/action.yml"
    click main "https://github.com/azure/login/blob/master/src/main.ts"
    click preCleanup "https://github.com/azure/login/blob/master/src/cleanup.ts"
    click loginConfig "https://github.com/azure/login/blob/master/src/common/LoginConfig.ts"
    click utils "https://github.com/azure/login/blob/master/src/common/Utils.ts"
    click cli "https://github.com/azure/login/blob/master/src/Cli/AzureCliLogin.ts"
    click psLogin "https://github.com/azure/login/blob/master/src/PowerShell/AzPSLogin.ts"
    click psBuilder "https://github.com/azure/login/blob/master/src/PowerShell/AzPSScriptBuilder.ts"
    click psUtils "https://github.com/azure/login/blob/master/src/PowerShell/AzPSUtils.ts"
    click lcTest "https://github.com/azure/login/blob/master/__tests__/LoginConfig.test.ts"
    click psLoginTest "https://github.com/azure/login/blob/master/__tests__/PowerShell/AzPSLogin.test.ts"
    click psBuilderTest "https://github.com/azure/login/blob/master/__tests__/PowerShell/AzPSScriptBuilder.test.ts"
    click CI "https://github.com/azure/login/tree/master/.github/workflows/"

    %% Styles
    classDef internal fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef external fill:#E2F0D9,stroke:#2C7A1B,color:#2C7A1B
    classDef hooks fill:#FFE5B4,stroke:#DA8C10,color:#A75D07
```
