You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Epic: Web UI (2/4) - Frontend Foundation & Authentication #54
This Issue (2/4): Frontend Foundation & Authentication
This task focuses on setting up the React frontend application and implementing the crucial GitHub authentication layer.
High-Level Goal
Bootstrap a new React application using Vite and Tailwind CSS.
Implement the full GitHub OAuth2 login flow using Passport.js on the backend.
Create protected routes to secure the dashboard from public access.
Build the main application layout (e.g., sidebar, header, content area).
Implementation Steps
Frontend Setup:
In the packages/dashboard directory, create a client subdirectory.
Initialize a new React project using Vite: npm create vite@latest client -- --template react-ts.
Add and configure Tailwind CSS for styling.
Backend Authentication:
Add passport, passport-github2, and express-session to the dashboard-api service.
Create a GitHub OAuth App and add the credentials to the .env file.
Configure the Passport GitHub strategy.
Implement the /auth/github and /auth/github/callback routes.
Create a middleware ensureAuthenticated to protect API endpoints.
Frontend Authentication Flow:
Create a LoginPage.js component with a "Login with GitHub" button that links to /api/auth/github.
Set up client-side routing (e.g., using react-router-dom) to handle protected routes. If a user is not authenticated, they should be redirected to the login page.
This code provides a robust starting point for the GitHub authentication flow in the Express API.
Reasoning:
Standard Practice: Uses Passport.js, the standard for authentication in the Node.js ecosystem.
Session-Based: Establishes a server-side session, which is a secure and common way to handle user logins in a web application.
Extensible: As discussed in our planning, this pattern makes it easy to add other authentication strategies (Bitbucket, etc.) in the future.
// packages/dashboard/auth.jsimportpassportfrom'passport';import{StrategyasGitHubStrategy}from'passport-github2';importsessionfrom'express-session';exportfunctionsetupAuth(app){app.use(session({secret: process.env.SESSION_SECRET,resave: false,saveUninitialized: false,}));app.use(passport.initialize());app.use(passport.session());passport.use(newGitHubStrategy({clientID: process.env.GH_OAUTH_CLIENT_ID,clientSecret: process.env.GH_OAUTH_CLIENT_SECRET,callbackURL: 'http://localhost:4000/api/auth/github/callback',},(accessToken,refreshToken,profile,done)=>{// Here you would find or create a user in your database.// For now, we'll just pass the profile through.console.log('User authenticated:',profile.username);returndone(null,profile);}));passport.serializeUser((user,done)=>done(null,user));passport.deserializeUser((obj,done)=>done(null,obj));// Routesapp.get('/api/auth/github',passport.authenticate('github',{scope: ['user:email','read:org']}));app.get('/api/auth/github/callback',passport.authenticate('github',{failureRedirect: '/login'}),(req,res)=>{// Successful authentication, redirect to the dashboard.res.redirect('/');});app.get('/api/auth/logout',(req,res)=>{req.logout();res.redirect('/login');});app.get('/api/auth/user',ensureAuthenticated,(req,res)=>{res.json(req.user);});}exportfunctionensureAuthenticated(req,res,next){if(req.isAuthenticated()){// Here you can add authorization logic, e.g.,// check if req.user.username is part of a specific GitHub org.returnnext();}res.status(401).json({error: 'Unauthorized'});}
Activity
integry commentedon Sep 12, 2025
Suggested Implementation: Passport.js Auth Backend
This code provides a robust starting point for the GitHub authentication flow in the Express API.
Reasoning:
propr-dev commentedon Sep 12, 2025
🤖 AI processing has started for this issue using claude-opus-4-20250514 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claude-opus-4-20250514ai-fix/54-epic-web-ui-2-4-frontend--20250913-0027-claude-opus-4-20250514-dlemainissue-54-20250913-0027-claude-opus-4-20250514-dlefix(ai): Resolve issue #54 - Epic: Web UI (2/4) - Frontend Foundation…
Merge pull request #58 from integry/ai-fix/54-epic-web-ui-2-4-fronten…