@moreillon/vue-oidc 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -21
- package/dist/composables/useAuth.d.ts +2 -2
- package/dist/composables/useAuth.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Vue OIDC
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Usage example
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```ts
|
|
6
|
+
import { createApp } from "vue";
|
|
7
|
+
import { createPinia } from "pinia";
|
|
8
|
+
import { auth } from "@moreillon/vue-oidc";
|
|
9
|
+
import App from "./App.vue";
|
|
10
|
+
import router from "./router";
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
const app = createApp(App);
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
const { VITE_OIDC_AUTHORITY, VITE_OIDC_CLIENT_ID } = import.meta.env;
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
app.use(auth, {
|
|
17
|
+
authority: VITE_OIDC_AUTHORITY,
|
|
18
|
+
client_id: VITE_OIDC_CLIENT_ID,
|
|
19
|
+
});
|
|
20
|
+
app.use(createPinia());
|
|
21
|
+
app.use(router);
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
See [Vite Configuration Reference](https://vite.dev/config/).
|
|
16
|
-
|
|
17
|
-
## Project Setup
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
npm install
|
|
23
|
+
app.mount("#app");
|
|
21
24
|
```
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
Then in your components:
|
|
24
27
|
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
```vue
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import { useAuth } from "@moreillon/vue-oidc";
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
const { user } = useAuth();
|
|
33
|
+
</script>
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
<template>
|
|
36
|
+
<h1>User</h1>
|
|
37
|
+
<p>
|
|
38
|
+
{{ user }}
|
|
39
|
+
</p>
|
|
40
|
+
</template>
|
|
33
41
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type OidcClient from "@moreillon/oidc-auth";
|
|
2
|
-
declare function login():
|
|
3
|
-
declare function logout():
|
|
2
|
+
declare function login(): void;
|
|
3
|
+
declare function logout(): void;
|
|
4
4
|
export default function (): {
|
|
5
5
|
client: import("vue").Ref<{
|
|
6
6
|
cookieName: string;
|
|
@@ -5,12 +5,12 @@ const access_token = ref(null);
|
|
|
5
5
|
function login() {
|
|
6
6
|
if (!client.value)
|
|
7
7
|
throw new Error("OIDC Client not instanciated");
|
|
8
|
-
|
|
8
|
+
client.value.login();
|
|
9
9
|
}
|
|
10
10
|
function logout() {
|
|
11
11
|
if (!client.value)
|
|
12
12
|
throw new Error("OIDC Client not instanciated");
|
|
13
|
-
|
|
13
|
+
client.value.logout();
|
|
14
14
|
}
|
|
15
15
|
export default function () {
|
|
16
16
|
return {
|