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

dianda-sso

v0.1.12

Published

店达sso登录中间件

Downloads

31

Readme

Install

npm install dianda-sso

Example

var express = require('express');
var app = express();
var ssoMiddleWare = require('dianda-sso');

// 单点登录配置
var ssoOptions = {
    key: 'sid',  // 登录中心 session id 对应的cookie key
    secret: 'sso-server', // cookie key 签名密钥
    redis: {	 // 登录中心 session 存储所使用的redis配置
        port: 6379,
        host: '127.0.0.0.1',
        db: 0
    },
    redirect: 'http://0.0.0.0:3000', // 登录中心地址用于重定向
    url: 'http://0.0.0.0:5000',  // 本系统地址,用于登录后回到本系统
    userKey: 'user',	// 用户session中获取user的键值
    systemId: 14,		// 本系统在权限系统中的id
    permissionUrl: 'http://0.0.0.0:5000' // 权限系统url用于获取权限菜单
}

// 本地开发时不使用单点登录,易于调试
if (env != 'development' && env != "devel" && env !="dev") {
    /* 创建中间件对象 */
    var sso = new ssoMiddleWare(ssoOptions);

    /** 对所有请求进行拦截,进行如下操作
    * 1、验证登录系统是否登录, 如果登录执行2,执行5
    * 2、验证本系统是否登录,如果登录则执行3,否则执行5
    * 3、验证通过访问目标url
    * 4、从权限系统获取菜单等信息,调用setSession函数进行设置, 设置成功执行3, 否则执行5
    * 5、重定向至登录中心 
    * @param {string} path 登录认证url
    * @param {function} setSession 设置本系统的session
    * @param {boolean} redirected 认证失败是否重 认证失败是否重 认证失败是否重定向
    * @param {Array} whiteList 路由白名单,这些路由无需认证, 支持正则, 函数fun(req)
    */
    app.use(sso.login('/user/login', function setSession(req, data, callback){
        /** setSession 用于认证成功时设置系统session
        @param req: 请求对象
        @param data: 权限系统菜单数据
        @param callback(err, session);
        */
    
    }, redirected, whiteList));

    /* 拦截退出操作,退出时重定向至sso登录中心 */
    app.use(sso.logout('/user/logout'));
}
app.user('/', require('./routers'));

配置说明

// 单点登录配置
var ssoOptions = {
    // 下述配置依赖于认证中心的配置
    key: 'sid',  // 登录中心 session id 对应的cookie key
    secret: 'sso-server', // cookie key 签名密钥
    redis: {	 // 登录中心 session 存储所使用的redis配置
        port: 6379,
        host: '127.0.0.0.1',
        db: 0
    },
    redirect: 'http://0.0.0.0:3000', // 登录中心地址用于重定向
    
    // 下面配置由各个系统的实际情况配置
    url: 'http://0.0.0.0:5000',  // 系统地址,用于登录后回到系统
    userKey: 'user',	// 用户session中获取user的键值
    systemId: 14,		// 本系统在权限系统中的id
    permissionUrl: 'http://0.0.0.0:5000' // 权限系统url用于获取权限菜单
}