or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

Multi-Strategy Authentication Handler

Build an authentication system that supports multiple Google OAuth authentication strategies for different user types. The system should allow legacy users to authenticate using one OAuth flow while new users can use a different OAuth flow.

Requirements

Your implementation should:

  1. Create two separate authentication strategies that can coexist in the same application
  2. Configure one strategy with consumer credentials (consumerKey and consumerSecret) for legacy authentication
  3. Configure another strategy with client credentials (clientID and clientSecret) for modern authentication
  4. Register both strategies with Passport under different names ('google-legacy' and 'google-modern')
  5. Implement verify callbacks for both strategies that handle the authentication tokens and user profile

Test Cases

  • The legacy strategy is registered with Passport under the name 'google-legacy' @test
  • The modern strategy is registered with Passport under the name 'google-modern' @test
  • Both strategies can coexist and be used simultaneously in the same application @test
  • The legacy strategy verify callback receives token, tokenSecret, profile, and done parameters @test
  • The modern strategy verify callback receives accessToken, refreshToken, profile, and done parameters @test

Implementation

@generates

API

/**
 * Configures and registers multiple Google OAuth strategies with Passport
 * @param {Object} passport - Passport instance
 * @param {Object} legacyConfig - Configuration for OAuth 1.0a strategy
 * @param {string} legacyConfig.consumerKey - Google consumer key
 * @param {string} legacyConfig.consumerSecret - Google consumer secret
 * @param {string} legacyConfig.callbackURL - Callback URL for legacy authentication
 * @param {Object} modernConfig - Configuration for OAuth 2.0 strategy
 * @param {string} modernConfig.clientID - Google client ID
 * @param {string} modernConfig.clientSecret - Google client secret
 * @param {string} modernConfig.callbackURL - Callback URL for modern authentication
 */
function setupMultiStrategyAuth(passport, legacyConfig, modernConfig) {
  // Implementation here
}

module.exports = { setupMultiStrategyAuth };

Dependencies { .dependencies }

passport-google-oauth { .dependency }

Provides Google OAuth authentication strategies for both OAuth 1.0a and OAuth 2.0.

@satisfied-by