egg-gymbo-auth
raw JSON → 1.3.9 verified Sat Apr 25 auth: no javascript maintenance
Egg.js authentication middleware plugin for Gymboree services. Current stable version is 1.3.9, compatible with Egg 1.x only (not 2.x). Provides JWT-based authentication middleware for Egg.js applications. Compared to generic auth libraries, it is tailored for Gymboree's internal authentication flow with opinionated defaults. Release cadence is low, with maintenance updates as needed due to Egg 1.x legacy support. No alternative non-Egg plugins cover the same Gymboree-specific auth patterns.
Common errors
error Error: Cannot find module 'egg-gymbo-auth' ↓
cause Package not installed or name misspelled.
fix
Run 'npm install egg-gymbo-auth' and check spelling in plugin.js.
error TypeError: app.middleware.gymboAuth is not a function ↓
cause Plugin not enabled or middleware not registered correctly.
fix
Ensure plugin is enabled in config/plugin.js and that the plugin has been loaded (check if it requires Egg 1.x).
Warnings
breaking This plugin only supports Egg 1.x, not Egg 2.x or later. ↓
fix Upgrade to Egg 2.x and use a compatible auth plugin.
gotcha The package name is 'egg-gymbo-auth', but the README header says 'egg-gymboree-auth'. Ensure you install the correct package. ↓
fix Install with 'npm install egg-gymbo-auth'.
deprecated Node.js >=8.0.0 required, but Node 8 is end-of-life. Consider upgrading Node version. ↓
fix Use Node.js 10+ or later.
Install
npm install egg-gymbo-auth yarn add egg-gymbo-auth pnpm add egg-gymbo-auth Imports
- default (plugin) wrong
exports.gymboAuth = { enable: true, package: 'egg-gymboree-auth', };correctexports.gymboAuth = { enable: true, package: 'egg-gymbo-auth', }; - middleware wrong
const gymboAuth = require('egg-gymbo-auth');correctapp.middleware.gymboAuth(ctx, next); - config wrong
const config = require('egg-gymbo-auth');correct// config/config.default.js exports.gymboAuth = { secret: 'your-secret', };
Quickstart
// config/plugin.js
exports.gymboAuth = {
enable: true,
package: 'egg-gymbo-auth',
};
// config/config.default.js
exports.gymboAuth = {
secret: process.env.AUTH_SECRET || 'default-secret',
ignore: ['/login', '/register'],
};
// app/router.js
module.exports = app => {
const { router, controller, middleware } = app;
router.get('/protected', middleware.gymboAuth(), controller.home.protected);
router.get('/login', controller.home.login);
};
// app/controller/home.js
exports.protected = async ctx => {
ctx.body = { message: 'Authenticated', user: ctx.state.user };
};
exports.login = async ctx => {
// dummy login
ctx.body = { token: 'fake-token' };
};