0.0.1 • Published 10 months ago

c2-sso-client-bug-fix v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

C2SSOClient

系统管理X单点登录node客户端,基于系统管理X1.1.3.2版本设计。

安装&使用

yarn add c2-sso-client
import initC2Client from 'c2-sso-client';

initC2Client({
    env: {
        C2_SYSX_NODE_SERVER_PORT: 3000, // 服务端口
        C2_SYSX_NODE_API_PREFIX: '/c2-node-api', // node接口前缀
        C2_SYSX_API_PREFIX: '/c2-sysx-api', // 系统管理X接口前缀
        C2_SYSX_BUSINESS_API_PREFIX: '/c2-sysx-business-api', // 业务模块接口前缀,可使用标准JSON以数组格式传入多个服务配置,如:["api-prefix-1", "api-prefix-2"]
        C2_SYSX_TARGET_URL: 'http://', // 系统管理X服务地址
        C2_SYSX_BUSINESS_TARGET_URL: 'http://', // 业务模块服务地址,可使用标准JSON以数组格式传入多个服务配置,如:["http://server-a.com", "http://server-b.com"]
        WEB_APP_TARGET_URL: 'http://', // 前端服务地址
        C2_SYSX_CLIENT_ID: '', // 客户端ID
        C2_SYSX_CLIENT_SECRET: '', // 客户端Secret
        C2_SYSX_CATEGORY_ID: '', // 系统管理X分类机构ID 
        C2_SYSX_WHITE_LIST: '', // 系统管理X白名单接口配置,以英文分号分割,
        C2_SYSX_BUSINESS_WHITE_LIST: '', // 业务模块白名单接口配置,可使用标准JSON以数组格式传入多个服务配置,如:["http://server-a.com", "http://server-b.com"]
        C2_SYSX_EXTENSIONS: '', // 扩展配置,满足前端需要动态配置参数的相关诉求
    },
    staticPath: '/src/web_app', // 静态资源目录,相对于项目根目录的路径
    isDebug: true, // 是否开启调试日志
    isRefreshToken: false // 是否开启刷新token的机制,由于系统X刷新token有bug,这个问题无解
});

node相关接口说明

公共模块

获取是否需要验证码校验

GET /common/need-captcha

query参数:

key类型备注
accountstring账号

获取验证码

GET /common/captcha

query参数:

key类型备注
randomstring随机数

获取分类机构ID

GET /common/category-id

获取客户端ID

GET /common/client-id

获取扩展配置

GET /common/extensions

用户模块

系统管理X登录

GET /user/system-x-login

query参数:

key类型备注
redirectUrlstring登录完成后重定向路径

本接口请使用浏览器地址栏访问,需要重定向到系统管理X完成登录授权。

自定义登录

POST /user/custom-login

body参数:

key类型备注
accountstring账号
passwordstring密码
captchaKeystring获取验证码时提交的随机数
captchaTextstring验证码

登出

POST /user/logout

鉴权

GET /user/authorization