AuthClinet
匹配4a单点SSO的前端工具包.
如何使用
当你熟悉单点SSO背后的流程后,你会发现其实变通使用的方法非常自由.但是我们强烈建议按照本文档的使用方法
$ npm install @jxstjh/auth-client
import { AuthClient } from '@jxstjh/auth-client'
const startupService = () => {
return new Promise((resolve, reject) => {
await doSomething() // ...根据实际情况执行其它前置逻辑
const ac = new AuthClient({
routerMode: 'history', // 'history'||'hash' 根据实际项目路由情况选择 缺省值'hash'
SSOServer: 'https://auth-test.jxwrd.gov.cn/',// 必填 sso认证地址
resourceCode: 'code', // 必填 resourceCode || 'code'
})
ac.on('error', (err) => {
return reject(err)
})
ac.on('inited', (e) => {
console.log(e)
// TODO:成功拿到用户信息及token
// 设置好vuex
return resolve()
})
})
}
startupService()
.then(()=>{
new Vue({
router,
store,
render: h => h(App)
})
})
.catch((err) => {
console.log(err)
})
流程说明
![oxwr3.png](https://e.im5i.com/2021/07/25/oxwr3.png)