Cline rules
.clinerules/project-overview.mdCline rules
Quality
48/100
Scores the file, not the repository.Length
1,332 words
14 headings · 0 code blocksRepository
0
— · pushed 222 days agoLast changed
3 days ago
First indexed 3 days ago.1## Brief overview23This Cline rule file provides project context for an **ASP.NET Core 8.0 training lab application** designed to teach Microsoft Entra ID authentication and authorization concepts. The project is organized into two modules with four hands-on labs where students learn by configuration only—no coding required during labs. All code is prebuilt with a focus on token exploration, authorization patterns, and multi-tier authentication flows.45## Project structure67The repository is organized into three modules:89**Module 1: Authentication & Authorization Basics** (`src/Module1/`)10- `WebAuthzDemo`: Main web application (Razor Pages) with authentication, token viewers, and protected API11- `TokenInspector`: Class library for JWT decode/format helpers (shared across all modules)1213**Module 2: Protected Web APIs & Cross-Tenant** (`src/Module2/`)14- `Labs.Shared`: Common models, constants, and configuration classes15- `Labs.MiddleTierApi`: Protected Web API with OBO flow to Microsoft Graph16- `Labs.ClientWeb`: Razor Pages client calling the protected API17- `Labs.CrossTenantDaemon`: Console daemon app for cross-tenant scenarios1819**Module 3: Public Client Authentication** (`src/Module3/`)20- `Labs.Cli`: Modern CLI tool demonstrating public client flows (PKCE and Device Code)2122**Documentation structure**:23- `docs/README.md`: Main course overview24- `docs/Module1/README.md`: Module 1 overview25- `docs/Module1/Lab1_Authentication.md`: Authentication lab (10-15 min)26- `docs/Module1/Lab2_SimpleAuthorization.md`: Authorization lab (10-15 min)27- `docs/Module2/README.md`: Module 2 overview28- `docs/Module2/Lab3_ProtectedWebAPI.md`: Protected API + OBO lab (12-15 min)29- `docs/Module2/Lab4_CrossTenantDaemon.md`: Cross-tenant daemon lab (12-15 min)30- `docs/Module3/README.md`: Module 3 overview31- `docs/Module3/Lab5_PublicClientCLI.md`: Public client CLI authentication lab (45-60 min)3233**Scripts**: `scripts/setup.ps1` for generating configuration templates3435## Tech stack requirements3637- **.NET 8** and **ASP.NET Core**38- **Microsoft.Identity.Web** and **Microsoft.Identity.Web.UI** packages39- **Authorization Code + PKCE** flow for interactive login40- **Microsoft Graph SDK** (optional) for delegated API calls41- **Razor Pages** for UI (lightweight, instructor-friendly)42- **Minimal APIs** or standard controllers for protected endpoints4344## Lab objectives4546**Module 1: Foundations**4748**Lab 1 (Authentication):**49- Sign in with Microsoft Entra ID50- Explore ID token vs Access token differences51- View claims in tabular format52- Understand token lifetimes and renewal concepts53- Simulate common errors (redirect URI mismatch, missing consent)5455**Lab 2 (Authorization - Simplified):**56- Understand the difference between authentication and authorization57- Test authentication-only authorization (`[Authorize]` attribute)58- Test local application-managed RBAC (self-assignment of Admin role)59- Call Microsoft Graph API with delegated permissions (`User.Read` scope)60- Understand that Entra ID provides identity while your app manages permissions6162**Module 2: Advanced Scenarios**6364**Lab 3 (Protected Web API + OBO Flow):**65- Expose and protect custom API with custom scopes (`api.read`)66- Understand token audience validation for APIs67- Implement scope-based authorization in ASP.NET Core68- Use On-Behalf-Of (OBO) flow to call Microsoft Graph from the API69- Explore three-tier authentication (Client → API → Graph)70- Compare delegated permissions vs custom API scopes7172**Lab 4 (Cross-Tenant Daemon):**73- Implement app-only (daemon) authentication with client credentials flow74- Understand application permissions vs delegated permissions75- Configure multi-tenant applications76- Acquire tokens for multiple Entra ID tenants77- Call Microsoft Graph without user context78- Explore cross-tenant consent and security considerations7980**Module 3: Public Client Authentication**8182**Lab 5 (Public Client CLI):**83- Understand why client secrets cannot be used in CLI/desktop/mobile apps84- Configure public client app registration in Entra ID85- Use Authorization Code + PKCE flow for interactive authentication86- Use Device Code flow for limited-input scenarios87- Explore token caching and security trade-offs for local storage88- Call Microsoft Graph API from a CLI tool89- Implement security best practices for public clients9091## Key constraints9293- **No coding by students**: All code must be prebuilt and functional94- **Configuration only**: Students only update `appsettings.json` or environment variables with Client ID, Tenant ID, etc.95- **Clear documentation**: Copy/paste ready instructions for app registration and API permissions96- **Error simulation**: Include UI toggles to demonstrate common mistakes for teaching moments97- **Security**: Never display refresh tokens; only explain them conceptually9899## Authentication patterns100101- Use **Microsoft.Identity.Web** patterns consistently throughout the application102- Implement **Authorization Code + PKCE** (not implicit flow)103- Configure via `appsettings.json`:104 - `AzureAd:Instance`, `AzureAd:Domain`, `AzureAd:TenantId`, `AzureAd:ClientId`, `AzureAd:CallbackPath`105- Maintain **HTTPS redirect URI consistency** across app configuration, README, and lab docs106- Use `launchSettings.json` with consistent HTTPS port107108## Authorization patterns109110**Module 1 patterns:**111- Define **named policies** for authorization requirements:112 - `RequireLocalAdmin`: Checks local role store for "Admin" role113- Apply `[Authorize]` attribute with or without policy names:114 - `[Authorize]` - Authentication-only (baseline)115 - `[Authorize(Policy = "RequireLocalAdmin")]` - Application-managed RBAC116- Use **in-memory role store** (`LocalRoleService`) for demonstration:117 - Maps user `oid` claim to application roles118 - Thread-safe using `ConcurrentDictionary`119 - Would use database in production120- Provide **role management endpoints**:121 - `POST /api/roles/assign-admin` - Self-assign Admin role122 - `POST /api/roles/remove-admin` - Remove Admin role123124**Module 2 patterns:**125- **Custom API scopes**: Define and expose API-specific scopes (e.g., `api.read`)126- **Scope-based authorization**: Validate scopes in access tokens with named policies127 - `RequireApiReadScope`: Checks for `api.read` scope claim128- **On-Behalf-Of (OBO) flow**: API exchanges user's access token for Graph token129- **App-only authentication**: Client credentials flow for daemon apps130- **Application permissions**: Tenant-wide permissions requiring admin consent131- **Multi-tenant support**: Cross-tenant token acquisition and consent132- Provide clear guidance when authorization fails with actionable error messages133134## UI/UX priorities135136- **Instructor-friendly**: Clean, simple UI focused on learning concepts137- **Token exploration**: Dedicated pages for ID Token, Access Token, and Claims138- **Pretty-print tokens**: Display header/payload/signature with key claims highlighted139- **Help sidebars**: Include conceptual notes (Authentication vs Authorization, ID token vs Access token, Scopes vs Roles)140- **External tools**: Provide "Copy token" button and "Open in jwt.ms" link141- **Error visibility**: Surface clear error messages for teaching moments142143## Development workflow144145- **Build without manual edits**: App must run immediately after configuration146- **Services encapsulation**: Use `TokenService` for token acquisition/decode, `GraphService` for Graph API calls147- **JWT helpers**: Centralize token parsing in `TokenInspector/JwtTools.cs`148- **Error handling**: Gracefully handle and display authorization failures with actionable guidance149150## Documentation standards151152- **Step-by-step instructions**: Numbered steps with exact portal actions153- **Copy/paste ready**: Provide exact JSON for app roles, exact URIs for redirect configuration154- **Troubleshooting section**: Cover common errors (AADSTS50011 redirect mismatch, missing consent, audience mismatch)155- **Screenshot placeholders**: Include markdown image links with descriptive captions156- **Teaching flow**: Guide instructors through logical progression (Sign In → ID Token → Access Token → Protected API)157158## Security considerations159160- **Refresh tokens**: Never display in UI; only explain concept and lifetime161- **PII logging**: Set `EnablePiiLogging=false` in production162- **Token redaction**: Safe redaction of signature section when displaying tokens163- **HTTPS only**: Enforce HTTPS for all redirect URIs and local development164165## Code organization principles166167- Keep `Program.cs` clean with clear authentication and authorization setup168- Encapsulate token operations in `TokenService`169- Encapsulate Graph API calls in `GraphService`170- Encapsulate local role management in `LocalRoleService`171- Separate authorization policies in `Authorization/Policies.cs`172- Use consistent naming: policy name `RequireLocalAdmin`173- Group related pages: `Pages/Tokens/` for token viewers174- Register `LocalRoleService` as singleton (static in-memory store)175176## Quality standards177178- All applications build and run without manual code edits after configuration179- Clear, actionable error messages for authorization failures180- **Module 1**: Three distinct authorization examples with clear learning goals:181 1. Authentication-only (baseline)182 2. Local application-managed roles (interactive self-assignment)183 3. Delegated permissions to Microsoft Graph184- **Module 2**: Advanced scenarios demonstrating real-world patterns:185 1. Custom API protection with scopes186 2. On-Behalf-Of (OBO) flow for API chaining187 3. App-only authentication for background services188 4. Cross-tenant authentication and consent189- UI provides educational value for token exploration and authorization concepts190- Interactive demonstrations show separation of identity (Entra ID) and permissions (app/API)191- Documentation enables self-service setup by instructors192- Module 1 requires minimal Azure configuration (User.Read is default)193- Module 2 demonstrates enterprise-grade authentication patterns194- All solutions use consistent architecture and coding patterns195196## Updates to this document197198- This project-overview.md file should be kept up to date as the poject evolves199- Any large change to the project must be reflected in this document200- Prefer to keep the current document structure and update the statements that need to be changed201
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| AzureAD/microsoft-authentication-library-for-dotnet.clinerules/csharp-guidelines.md · 1.5k | Cline rules | testlint-formatstyletypes+2 | 75/100 | 3 days ago | |
| AzureAD/microsoft-authentication-library-for-dotnet.clinerules/msal-guidelines.md · 1.5k | Cline rules | teststylearchtesting-strategy+3 | 66/100 | 3 days ago | |
| AzureAD/microsoft-authentication-library-for-dotnet.clinerules/cline-instructions.md · 1.5k | Cline rules | archtypestesting-strategyagent-behaviour | 48/100 | 3 days ago | |
| AzureAD/microsoft-authentication-library-for-dotnet.clinerules/ai-guidelines.md · 1.5k | Cline rules | no sections | 16/100 | 3 days ago |
