Aleph Alph Alpha lib Auth (英语)
@aleph-alpha/lib-auth (英语)
这个项目对下列项目作了调整: oidc-client-ts 和一些卫兵,你可以使用 在vur -routter 或者其他路线你喜欢.
npm install @aleph-alpha/lib-auth
pnpm add @aleph-alpha/lib-auth
AuthManager 的示例设置
import { createAuthManager } from '@aleph-alpha/lib-auth';
export default createAuthManager('issuer', 'clientId', 'http:localhost:5173', '/callback');
Vue-Router 有警卫的例子
import authManager from 'your-path/auth';
import { guardForEntryPage, guardForCallbackPage } from '@aleph-alpha/lib-auth'
const routes = {
path: '/',
name: 'Home',
beforeEnter: (to, from, next) => {
guardForEntryPage(authManager, () => next());
},
},
{
path: '/callback',
name: 'LoginCallback',
beforeEnter: (to, from, next) => {
guardForCallbackPage(authManager, () => next());
},
},