npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

medusa-plugin-auth-v2

v1.0.0

Published

Authentication plugin for Medusa V2

Readme

Medusa Authentication Plugin (v2)

Features

  • 🔐 Google OAuth Authentication (fully implemented)
  • 🖼️ Beautiful Success & Error Pages
  • 🔄 Enhanced Profile Data with Avatar Display
  • 📱 Mobile-Friendly Interface
  • 🛡️ TypeScript Support
  • 🐳 Docker Test Environment Included

Screenshots

Initial Login Screen

Successful Authentication Screen

Prerequisites

Quick Start with Docker

The plugin comes with a complete test environment using Docker Compose, which includes:

  • Medusa backend with the auth plugin pre-configured
  • Admin dashboard
  • PostgreSQL database
  • Redis for caching

Running the Docker Environment

# Clone the repository (if not already done)
git clone <repository-url>
cd medusa-plugin-auth-v2

# Start the Docker environment
docker-compose up -d

Access the services:

  • Medusa Backend: http://localhost:9000
  • Medusa Admin: http://localhost:7001
  • Authentication URLs:
    • Start Google OAuth: http://localhost:9000/store/auth/google
    • Success Page: http://localhost:9000/auth/success
    • Error Page: http://localhost:9000/auth/error

Testing OAuth Flow

  1. Configure your OAuth credentials in a .env file (see .env-example)
  2. Restart the Docker containers to apply the changes
  3. Navigate to http://localhost:9000/store/auth/google to start the OAuth flow
  4. After successful authentication, you'll be redirected to the success page

Installation (without Docker)

npm install medusa-plugin-auth-v2
# or
yarn add medusa-plugin-auth-v2

Configuration

Add the plugin to your medusa-config.js or medusa-config.ts:

const { defineConfig } = require('@medusajs/medusa')

module.exports = defineConfig({
  plugins: [
    // ... other plugins
    {
      resolve: "medusa-plugin-auth-v2",
      options: {
        // JWT settings
        jwt: {
          secret: process.env.JWT_SECRET,
          expiresIn: "7d"
        },
        // Cookie settings
        cookie: {
          name: "medusa-auth",
          secure: process.env.NODE_ENV === "production",
          maxAge: 1000 * 60 * 60 * 24 * 7 // 7 days
        },
        // OAuth provider configurations
        google: {
          clientID: process.env.GOOGLE_CLIENT_ID,
          clientSecret: process.env.GOOGLE_CLIENT_SECRET,
          callbackURL: process.env.GOOGLE_CALLBACK_URL,
          // Strategy options
          strategyOptions: {
            scope: ["profile", "email"]
          }
        }
      }
    }
  ]
})

Authentication Flow

The plugin provides these endpoints:

| Endpoint | Method | Description | |----------|--------|-------------| | /store/auth/google | GET/POST | Starts Google OAuth flow | | /store/auth/google/callback | GET | Google OAuth callback handler | | /auth/success | GET | Success page with user profile information | | /auth/error | GET | Error page with detailed error information |

Migration from v1 to v2

If you're migrating from the v1 version of the plugin, please see our detailed Migration Guide.

Key Changes

  1. File-based Routes: Routes now use Medusa v2's file-based routing system
  2. Function-based Subscribers: Subscribers now use functions instead of classes
  3. Container API Changes: Container registration and resolution patterns have changed
  4. New Success/Error Pages: Enhanced pages with user details and error information
  5. Enhanced Profile Data: Better handling of user profile information

Troubleshooting

Common Issues

  1. Profile Picture Not Displaying: Add referrerpolicy="no-referrer" to image tags for Google profile pictures
  2. "resolver.resolve is not a function": This indicates a container resolution issue in Medusa v2
  3. Authentication Flow Starts But Never Completes: Check that your callback URLs are correctly configured

Docker Environment Issues

  1. Port Conflicts: If ports 9000 or 7001 are already in use, modify the docker-compose.yml file
  2. Environment Variables: Ensure all required variables are set in your .env file
  3. Container Rebuilding: Use docker-compose up -d --build to rebuild containers after code changes

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License (C) 2025 Paul Pierre