-
Notifications
You must be signed in to change notification settings - Fork 1
Update documentation for SWA authentication and implemented frontend #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,14 +7,17 @@ The solution consists of three projects: | |||||
| - Bezalu.ProjectReporting.Shared (DTO contracts shared by both) | ||||||
|
|
||||||
| ## Data Flow | ||||||
| 1. User enters Project ID in Web UI. | ||||||
| 2. Front end POSTs projectId to `/api/reports/project-completion`. | ||||||
| 3. API fetches project, phases, tickets, notes from ConnectWise. | ||||||
| 4. API builds `ProjectCompletionReportResponse` and invokes Azure OpenAI to produce `AiGeneratedSummary`. | ||||||
| 5. JSON returned to client; client renders summary markdown using Markdig. | ||||||
| 6. User initiates PDF download; front end POSTs the full report JSON to `/api/reports/project-completion/pdf`. | ||||||
| 7. API composes PDF using QuestPDF with supplied data (skip re-fetch & AI). | ||||||
| 8. Client receives PDF bytes and triggers browser download via JS interop. | ||||||
| 1. User accesses Blazor WebAssembly app via Azure Static Web Apps. | ||||||
| 2. Static Web Apps enforces authentication via Azure AD (Entra ID). | ||||||
| 3. User enters Project ID in Web UI. | ||||||
| 4. Front end POSTs projectId to `/api/reports/project-completion` (with SWA auth cookies). | ||||||
| 5. SWA validates authentication and forwards request to Azure Functions. | ||||||
| 6. API fetches project, phases, tickets, notes from ConnectWise. | ||||||
| 7. API builds `ProjectCompletionReportResponse` and invokes Azure OpenAI to produce `AiGeneratedSummary`. | ||||||
| 8. JSON returned to client; client renders summary markdown using Markdig. | ||||||
| 9. User initiates PDF download; front end POSTs the full report JSON to `/api/reports/project-completion/pdf`. | ||||||
| 10. API composes PDF using QuestPDF with supplied data (skip re-fetch & AI). | ||||||
| 11. Client receives PDF bytes and triggers browser download via JS interop. | ||||||
|
|
||||||
| ## Key Services | ||||||
| - `IConnectWiseApiClient`: wraps HTTP calls to ConnectWise endpoints. | ||||||
|
|
@@ -26,8 +29,18 @@ The solution consists of three projects: | |||||
| - POST for PDF avoids second expensive aggregation call. | ||||||
| - Markdown + Markdig chosen for flexibility in AI summary formatting. | ||||||
| - QuestPDF chosen for deterministic server-side PDF rendering. | ||||||
| - **Azure Static Web Apps** provides integrated hosting, authentication, and API routing. | ||||||
| - **Function AuthorizationLevel.Anonymous** used because authentication is enforced upstream by SWA. | ||||||
|
||||||
| - **Function AuthorizationLevel.Anonymous** used because authentication is enforced upstream by SWA. | |
| - **Azure Functions use AuthorizationLevel.Anonymous** because authentication is enforced upstream by SWA. |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider specifying the full path to the configuration file (e.g., "Bezalu.ProjectReporting.Web/staticwebapp.config.json") to help readers locate this file in the project structure.
| - `staticwebapp.config.json` enforces `authenticated` role for `/api/*` routes | |
| - `Bezalu.ProjectReporting.Web/staticwebapp.config.json` enforces `authenticated` role for `/api/*` routes |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,21 +2,38 @@ | |||||
|
|
||||||
| ## Azure Static Web Apps + Azure Functions | ||||||
| - Front end (Blazor WASM) deployed to Static Web Apps. | ||||||
| - API (Azure Functions) either integrated (api folder) or separate Functions App. | ||||||
| - API (Azure Functions) integrated via SWA's managed Functions (api folder) or linked to separate Functions App. | ||||||
| - **Authentication** handled by Static Web Apps with Azure AD integration. | ||||||
|
|
||||||
| ## Steps (Integrated Deployment) | ||||||
| 1. Create Azure Static Web App resource in Azure Portal. | ||||||
| 2. Configure Azure AD authentication provider in SWA settings. | ||||||
| 3. Set `api_location` to point to Azure Functions project folder during SWA build. | ||||||
| 4. Configure Application Settings for ConnectWise + Azure OpenAI in SWA or linked Functions App. | ||||||
| 5. Deploy via GitHub Actions (auto-configured by SWA) or manual deployment: | ||||||
| - Front-end: `dotnet publish -c Release Bezalu.ProjectReporting.Web` | ||||||
| - API: Functions automatically deployed with SWA or via `func azure functionapp publish <name>` | ||||||
|
|
||||||
| ## Steps (Separate Functions App) | ||||||
| 1. Create Azure Functions App (Isolated .NET runtime) and configure Application Settings for ConnectWise + Azure OpenAI. | ||||||
| 2. Deploy API project via `func azure functionapp publish <name>` or CI. | ||||||
| 3. Create Static Web App and set `api_location` to Functions App if integrated, else configure front end to call external API base URL. | ||||||
| 4. Upload front-end build (`dotnet publish -c Release Bezalu.ProjectReporting.Web`). | ||||||
| 3. Create Static Web App and link to external Functions App or configure front end to call external API base URL. | ||||||
| 4. Configure Azure AD authentication in Static Web Apps settings. | ||||||
| 5. Upload front-end build output to SWA. | ||||||
|
|
||||||
| ## Configuration Keys | ||||||
| - `ConnectWise:*` | ||||||
| - `AzureOpenAI:Endpoint` | ||||||
| - `AzureOpenAI:DeploymentName` | ||||||
|
|
||||||
| ## Authentication | ||||||
| - Add Entra ID or other auth on Static Web Apps; issue front-end access token; secure Functions with Easy Auth or custom. | ||||||
| - **Azure Static Web Apps** integrated with **Azure AD (Entra ID)** for authentication | ||||||
| - Configure authentication provider in Azure Portal under SWA > Settings > Authentication | ||||||
| - `staticwebapp.config.json` enforces authentication: | ||||||
|
||||||
| - `staticwebapp.config.json` enforces authentication: | |
| - `Bezalu.ProjectReporting.Web/staticwebapp.config.json` enforces authentication: |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,17 +1,32 @@ | ||||||
| # Front-End (Blazor WebAssembly) | ||||||
|
|
||||||
| ## Overview | ||||||
| The front-end is a Blazor WebAssembly application using Microsoft Fluent UI components, deployed on Azure Static Web Apps with integrated Azure AD authentication. | ||||||
|
|
||||||
| ## Key Behaviors | ||||||
| - User must authenticate via Azure AD before accessing the application. | ||||||
| - User enters Project ID; triggers report fetch. | ||||||
| - Displays metrics in Fluent UI components (cards, tabs, data grids, accordion). | ||||||
| - AI summary rendered as markdown using Markdig. | ||||||
| - PDF download posts existing report JSON to API; no recomputation. | ||||||
|
|
||||||
| ## Authentication | ||||||
| - **Azure Static Web Apps** handles authentication via Azure AD (Entra ID) | ||||||
| - Configured in `staticwebapp.config.json`: | ||||||
|
||||||
| - Configured in `staticwebapp.config.json`: | |
| - Configured in `Bezalu.ProjectReporting.Web/staticwebapp.config.json`: |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent terminology: This line refers to "SWA session cookies" while line 28 refers to "SWA authentication cookies". Consider using consistent terminology throughout the documentation to refer to the same concept.
| - SWA session cookies automatically included in API requests | |
| - SWA authentication cookies automatically included in API requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states "configured in
staticwebapp.config.json" but doesn't specify where this file is located. Consider adding the file path (e.g., "configured inBezalu.ProjectReporting.Web/staticwebapp.config.json") to help readers locate this configuration file.