docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build an authentication server that supports Google OAuth login across multiple deployment environments (development, staging, production) with environment-specific callback URLs.
Your solution must:
development, staging, and productionhttp://localhost:3000/auth/google/callbackhttps://staging.example.com/auth/google/callbackhttps://example.com/auth/google/callbackprocess.env.NODE_ENV (defaults to development)GET /auth/google - Initiates Google OAuth flowGET /auth/google/callback - Handles OAuth callbackGET /profile - Protected route showing authenticated user infoGET / - Home page displaying current environment and authentication status/profile/ with error informationWhen NODE_ENV is set to development, the authentication strategy should use http://localhost:3000/auth/google/callback as the callback URL.
Test steps:
NODE_ENV=developmenthttp://localhost:3000/auth/google/callbackWhen NODE_ENV is set to staging, the authentication strategy should use https://staging.example.com/auth/google/callback as the callback URL.
Test steps:
NODE_ENV=staginghttps://staging.example.com/auth/google/callbackWhen NODE_ENV is set to production, the authentication strategy should use https://example.com/auth/google/callback as the callback URL.
Test steps:
NODE_ENV=productionhttps://example.com/auth/google/callbackCreate the following files:
server.js - Main Express server with OAuth configurationserver.test.js - Test file containing the test cases aboveProvides Google OAuth 2.0 authentication strategy for authenticating users.
Web framework for creating the HTTP server and handling routes.
Session middleware for managing user sessions after authentication.
clientID and clientSecret (e.g., 'YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET')