File tree Expand file tree Collapse file tree 16 files changed +1960
-608
lines changed Expand file tree Collapse file tree 16 files changed +1960
-608
lines changed Original file line number Diff line number Diff line change
1
+ # enable TypeScript bundler module resolution - https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler
2
+ experimental.typescriptBundlerResolution=true
Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
3
4
+ ## v0.0.14
5
+
6
+ [compare changes](https://github.com/Atinux/nuxt-auth-utils/compare/v0.0.13...v0.0.14)
7
+
8
+ ### 🚀 Enhancements
9
+
10
+ - Added keycloak as oauth provider ([#23](https://github.com/Atinux/nuxt-auth-utils/pull/23))
11
+
12
+ ### 🏡 Chore
13
+
14
+ - Test bundler module resolution ([#32](https://github.com/Atinux/nuxt-auth-utils/pull/32))
15
+ - Update deps ([9d6b258](https://github.com/Atinux/nuxt-auth-utils/commit/9d6b258))
16
+
17
+ ### ❤️ Contributors
18
+
19
+ - Sébastien Chopin ([@Atinux](http://github.com/Atinux))
20
+ - Yue JIN
21
+
22
+
23
+ ## v0.0.13
24
+
25
+ [compare changes](https://github.com/Atinux/nuxt-auth-utils/compare/v0.0.12...v0.0.13)
26
+
27
+ ### 🏡 Chore
28
+
29
+ - Rename session from verify to fetch ([10694e9](https://github.com/Atinux/nuxt-auth-utils/commit/10694e9))
30
+
31
+ ### ❤️ Contributors
32
+
33
+ - Sébastien Chopin ([@Atinux](http://github.com/Atinux))
34
+
35
+ ## v0.0.12
36
+
37
+ [compare changes](https://github.com/Atinux/nuxt-auth-utils/compare/v0.0.11...v0.0.12)
38
+
39
+ ### 🩹 Fixes
40
+
41
+ - Correct arguments for hooks ([6e0193e](https://github.com/Atinux/nuxt-auth-utils/commit/6e0193e))
42
+
43
+ ### ❤️ Contributors
44
+
45
+ - Sébastien Chopin ([@Atinux](http://github.com/Atinux))
46
+
47
+ ## v0.0.11
48
+
49
+ [compare changes](https://github.com/Atinux/nuxt-auth-utils/compare/v0.0.10...v0.0.11)
50
+
51
+ ### 🚀 Enhancements
52
+
53
+ - Add sessionHooks to extend user sessions ([c470319](https://github.com/Atinux/nuxt-auth-utils/commit/c470319))
54
+
55
+ ### ❤️ Contributors
56
+
57
+ - Sébastien Chopin ([@Atinux](http://github.com/Atinux))
58
+
4
59
## v0.0.10
5
60
6
61
[compare changes](https://github.com/Atinux/nuxt-auth-utils/compare/v0.0.9...v0.0.10)
Original file line number Diff line number Diff line change @@ -154,6 +154,7 @@ It can also be set using environment variables:
154
154
- Discord
155
155
- GitHub
156
156
- Google
157
+ - Keycloak
157
158
- LinkedIn
158
159
- Microsoft
159
160
- Spotify
@@ -188,6 +189,28 @@ export default oauth.githubEventHandler({
188
189
189
190
Make sure to set the callback URL in your OAuth app settings as `<your-domain>/auth/github`.
190
191
192
+ ### Extend Session
193
+
194
+ We leverage hooks to let you extend the session data with your own data or to log when the user clear its session.
195
+
196
+ ```ts
197
+ // server/plugins/session.ts
198
+ export default defineNitroPlugin(() => {
199
+ // Called when the session is fetched during SSR for the Vue composable (/api/_auth/session)
200
+ // Or when we call useUserSession().fetch()
201
+ sessionHooks.hook('fetch', async (session, event) => {
202
+ // extend User Session by calling your database
203
+ // or
204
+ // throw createError({ ... }) if session is invalid for example
205
+ })
206
+
207
+ // Called when we call useServerSession().clear() or clearUserSession(event)
208
+ sessionHooks.hook('clear', async (session, event) => {
209
+ // Log that user logged out
210
+ })
211
+ })
212
+ ```
213
+
191
214
## Development
192
215
193
216
```bash
Original file line number Diff line number Diff line change 1
1
{
2
2
"name": "nuxt-auth-utils",
3
- "version": "0.0.10 ",
3
+ "version": "0.0.14 ",
4
4
"description": "Minimalist Auth module for Nuxt with SSR",
5
5
"repository": "Atinux/nuxt-auth-utils",
6
6
"license": "MIT",
30
30
"test:watch": "vitest watch"
31
31
},
32
32
"dependencies": {
33
- "@nuxt/kit": "^3.8.2 ",
33
+ "@nuxt/kit": "^3.9.0 ",
34
34
"defu": "^6.1.3",
35
+ "hookable": "^5.5.3",
35
36
"ofetch": "^1.3.3",
36
37
"ohash": "^1.1.3"
37
38
},
38
39
"devDependencies": {
39
- "@iconify-json/simple-icons": "^1.1.82 ",
40
+ "@iconify-json/simple-icons": "^1.1.86 ",
40
41
"@nuxt/devtools": "latest",
41
42
"@nuxt/eslint-config": "^0.2.0",
42
- "@nuxt/module-builder": "^0.5.4 ",
43
- "@nuxt/schema": "^3.8.2 ",
44
- "@nuxt/test-utils": "^3.8.1 ",
45
- "@nuxt/ui": "^2.11.0 ",
46
- "@nuxt/ui-pro": "^0.5.0 ",
47
- "@types/node": "^20.10.4 ",
43
+ "@nuxt/module-builder": "^0.5.5 ",
44
+ "@nuxt/schema": "^3.9.0 ",
45
+ "@nuxt/test-utils": "^3.9.0 ",
46
+ "@nuxt/ui": "^2.11.1 ",
47
+ "@nuxt/ui-pro": "^0.6.1 ",
48
+ "@types/node": "^20.10.6 ",
48
49
"changelogen": "^0.5.5",
49
- "eslint": "^8.55 .0",
50
- "nuxt": "^3.8.2 ",
50
+ "eslint": "^8.56 .0",
51
+ "nuxt": "^3.9.0 ",
51
52
"typescript": "^5.3.3",
52
- "vitest": "^1.0.2 ",
53
- "vue-tsc": "^1.8.25 "
53
+ "vitest": "^1.1.3 ",
54
+ "vue-tsc": "^1.8.27 "
54
55
}
55
56
}
Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ NUXT_OAUTH_DISCORD_CLIENT_SECRET=
25
25
# Battle.net OAuth
26
26
NUXT_OAUTH_BATTLEDOTNET_CLIENT_ID=
27
27
NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET=
28
+ # Keycloak OAuth
29
+ NUXT_OAUTH_KEYCLOAK_CLIENT_ID=
30
+ NUXT_OAUTH_KEYCLOAK_CLIENT_SECRET=
31
+ NUXT_OAUTH_KEYCLOAK_SERVER_URL=
32
+ NUXT_OAUTH_KEYCLOAK_REALM=
28
33
# LinkedIn
29
34
NUXT_OAUTH_LINKEDIN_CLIENT_ID=
30
35
NUXT_OAUTH_LINKEDIN_CLIENT_SECRET=
Original file line number Diff line number Diff line change @@ -50,13 +50,18 @@ const providers = computed(() => [
50
50
disabled: Boolean(user.value?.microsoft),
51
51
icon: 'i-simple-icons-microsoft',
52
52
},
53
+ {
54
+ label: user.value?.keycloak?.preferred_username || 'Keycloak',
55
+ to: '/auth/keycloak',
56
+ disabled: Boolean(user.value?.keycloak),
57
+ icon: 'i-simple-icons-redhat'
58
+ },
53
59
{
54
60
label: user.value?.linkedin?.email || 'LinkedIn',
55
61
to: '/auth/linkedin',
56
62
disabled: Boolean(user.value?.linkedin),
57
63
icon: 'i-simple-icons-linkedin',
58
64
}
59
-
60
65
].map(p => ({
61
66
...p,
62
67
prefetch: false,
Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ declare module '#auth-utils' {
9
9
microsoft?: any;
10
10
discord?: any
11
11
battledotnet?: any
12
+ keycloak?: any
12
13
linkedin?: any
13
14
}
15
+ extended?: any
14
16
loggedInAt: number
15
17
}
16
18
}
Original file line number Diff line number Diff line change 8
8
"generate": "nuxi generate"
9
9
},
10
10
"dependencies": {
11
- "nuxt": "3.8.1 ",
11
+ "nuxt": "^3.9.0 ",
12
12
"nuxt-auth-utils": "latest",
13
- "vue": "3.3.8 "
13
+ "vue": "^3.4.5 "
14
14
}
15
15
}
Original file line number Diff line number Diff line change
1
+ export default defineNitroPlugin(() => {
2
+ sessionHooks.hook('fetch', async (session) => {
3
+ // Extend User Session
4
+ // Or throw createError({ ... }) if session is invalid
5
+ session.extended = {
6
+ fromHooks: true
7
+ }
8
+ })
9
+
10
+ sessionHooks.hook('clear', async (session) => {
11
+ // Log that user logged out
12
+ console.log('User logged out')
13
+ })
14
+ })
15
+
Original file line number Diff line number Diff line change
1
+ export default oauth.keycloakEventHandler({
2
+ async onSuccess(event, { user }) {
3
+ await setUserSession(event, {
4
+ user: {
5
+ keycloak: user,
6
+ },
7
+ loggedInAt: Date.now(),
8
+ })
9
+
10
+ return sendRedirect(event, '/')
11
+ },
12
+ })
You can’t perform that action at this time.
0 commit comments