docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a user authentication service for a web application that implements Google OAuth 2.0 authentication with custom session handling.
Your service should implement the following functionality:
Configure Google OAuth 2.0 authentication with the following requirements:
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and CALLBACK_URL for configurationImplement custom session handling with these features:
Implement the following routes:
GET /auth/google - Initiates the Google OAuth flowGET /auth/google/callback - Handles the OAuth callbackGET /profile - Returns the authenticated user's profile (requires authentication)GET /logout - Logs out the user and destroys the sessionMaintain an in-memory store of users with the following structure:
When a user authenticates for the first time, create a new user record. For returning users, retrieve their existing record.
/profile without authentication redirects to /auth/google @test/**
* Configures and returns an Express application with Google OAuth authentication
* and session management.
*
* @returns {Express.Application} Configured Express application
*/
function createAuthService() {
// IMPLEMENTATION HERE
}
module.exports = { createAuthService };Provides Google OAuth 2.0 authentication strategy for Passport.
Authentication middleware for Node.js that handles authentication strategies and session integration.
Session middleware for Express that manages user sessions.
Web application framework for Node.js.