pinia-oidc
📦 Install
pnpm i pinia-oidc
yarn pinia-oidc
Usage
//oidc.ts
import { defineStore } from "pinia";
import { store } from "@/pinia";
import {
piniaOidcCreateRouterMiddleware,
piniaOidcCreateStoreModule,
} from "pinia-oidc";
const oidcSettings = {
authority: "",
scope: "",
client_id: "",
client_secret: "",
redirectUri: origin + "/oidc-callback",
popupRedirectUri: origin + "/oidc-popup-callback",
response_type: "",
automaticSilentRenew: true,
automaticSilentSignin: false,
silentRedirectUri: origin + "/silent-renew-oidc.html",
acr_values: null,
};
//创建oidc储存
export const useOidcStore = defineStore(
piniaOidcCreateStoreModule(oidcSettings)
);
//创建路由中间件
router.beforeEach(piniaOidcCreateRouterMiddleware(useOidcStore()));
pinia state
const oidcStore = useOidcStore();
access_token: string | null;
id_token: string | null;
refresh_token: string | null;
user: any | null;
scopes: any | null;
is_checked: boolean;
events_are_bound: boolean;
error: any;
pinia actions
const oidcStore = useOidcStore();
//signOutOidc => Promise<void>
oidcStore.signOutOidc();
//oidcSignInCallback => Promise<string>
oidcStore.oidcSignInCallback().then((url) => {
console.log(url);
});
//oidcSignInPopupCallback => Promise<void>
oidcStore.oidcSignInPopupCallback();
//authenticateOidc => Promise<void>
//将当前窗口重定向到授权端点
oidcStore.authenticateOidc();
//setOidcAuth(arg) => Promise<void>
//设置pinia state
oidcStore.setOidcAuth(arg);
Related Packages
vue-oidc-client
Wrapper around oidc-client-js to to better work in a Vue application with Vue Ro...
96,754
105
vue-oidc-client-deep-linking
Wrapper around oidc-client-js to better work in a Vue application with Vue Route...
2,792
105
jl-vue-oidc-client
Wrapper around oidc-client-js to to better work in a Vue application with Vue Ro...
2,699
Version History
| Version | Released | License |
|---|---|---|
| 1.0.10 | MIT | |
| 1.0.9 | MIT | |
| 1.0.8 | MIT | |
| 1.0.7 | MIT | |
| 1.0.6 | MIT | |
| 1.0.5 | MIT | |
| 1.0.4 | MIT | |
| 1.0.3 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT |