How shivanik97/msal-auth-vue works
Project Type and Purpose
• This is a single‐page application (SPA) built with Vue 3 and Vite.
• It serves as a starter template for integrating Microsoft Authentication Library (MSAL) into a Vue 3 app.
• There is no custom backend in this repo; authentication flows are handled by MSAL against Azure AD (or Microsoft Identity Platform).
File Structure Analysis
• Top‐Level
• index.html: SPA entry point
• vite.config.ts: Vite build/dev configuration
• package.json / tsconfig*.json / eslint, prettier configs
• src/
• main.ts: app bootstrapping, plugin registration (MSAL, router)
• App.vue: root component
• router/index.ts: Vue Router setup, routes to views
• config/msalConfig.ts & useAuth.ts: MSAL client-side configuration and composable for authentication
• views/: top-level pages (HomeView, AboutView)
• assets/: CSS and static assets
Key Insights from README
• This repo is a template: it provides boilerplate for Vue 3 + TypeScript + MSAL.
• Emphasis on IDE setup, type support.
Main Components
A. Browser (client)
B. Static File Server / CDN or Vite Dev Server
C. Vue 3 SPA
1. index.html
2. main.ts (bootstraps App.vue, router, MSAL plugin)
3. Router Layer (router/index.ts → HomeView, AboutView)
4. MSAL Auth Module (config/msalConfig.ts + composable useAuth.ts)
6. Assets (CSS under src/assets and public/)
D. External Service
• Microsoft Identity Platform / Azure AD endpoints
Relationships & Data Flows
• User opens the app URL → Browser requests index.html & JS bundles from Static Server
• main.ts initializes Vue, registers MSAL plugin with msalConfig
• User navigates via Vue Router → appropriate View loads
• When user triggers sign-in, useAuth composable calls MSAL API
→ Browser redirects to Azure AD login endpoint
→ User authenticates, Azure AD returns token → MSAL stores token in browser memory/cache
• App uses token to call protected resources (e.g., Microsoft Graph or future APIs)
Architectural Patterns & Design Principles
• Component‐Based UI (Vue Single File Components)
• Plugin Pattern (MSAL as a Vue plugin via main.ts)
• Router‐driven navigation (SPA routing)
• Separation of concerns: config vs. composables vs. UI
Essential Elements
• Notes on where to extend (e.g., “Insert API Service here for Graph calls”)