@openape/nuxt-auth-sp 0.1.3 → 0.1.5
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/dist/module.d.mts +2 -2
- package/dist/module.d.ts +2 -2
- package/dist/module.json +2 -2
- package/dist/module.mjs +1 -1
- package/dist/runtime/middleware/openape-auth.js +0 -1
- package/dist/runtime/server/api/callback.get.js +0 -3
- package/dist/runtime/server/api/login.post.js +0 -2
- package/dist/runtime/server/api/logout.post.js +0 -2
- package/dist/runtime/server/api/me.get.js +0 -2
- package/dist/runtime/server/routes/well-known/sp-manifest.json.get.js +1 -3
- package/dist/runtime/server/utils/sp-config.js +1 -3
- package/dist/runtime/server/utils/sp-session.js +0 -2
- package/package.json +6 -14
- package/LICENSE +0 -21
- package/README.md +0 -122
package/dist/module.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
3
|
interface ModuleOptions {
|
|
4
4
|
spId: string;
|
|
@@ -6,7 +6,7 @@ interface ModuleOptions {
|
|
|
6
6
|
sessionSecret: string;
|
|
7
7
|
openapeUrl: string;
|
|
8
8
|
}
|
|
9
|
-
declare const _default:
|
|
9
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
10
10
|
|
|
11
11
|
export { _default as default };
|
|
12
12
|
export type { ModuleOptions };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
3
|
interface ModuleOptions {
|
|
4
4
|
spId: string;
|
|
@@ -6,7 +6,7 @@ interface ModuleOptions {
|
|
|
6
6
|
sessionSecret: string;
|
|
7
7
|
openapeUrl: string;
|
|
8
8
|
}
|
|
9
|
-
declare const _default:
|
|
9
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
10
10
|
|
|
11
11
|
export { _default as default };
|
|
12
12
|
export type { ModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineNuxtRouteMiddleware, navigateTo } from "#imports";
|
|
2
|
-
import { useOpenApeAuth } from "../composables/useOpenApeAuth.js";
|
|
3
2
|
export default defineNuxtRouteMiddleware(async () => {
|
|
4
3
|
const { user, fetchUser, loading } = useOpenApeAuth();
|
|
5
4
|
if (loading.value) await fetchUser();
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery, getRequestURL, sendRedirect } from "h3";
|
|
2
1
|
import { handleCallback } from "@openape/auth";
|
|
3
|
-
import { getFlowState, getSpConfig, clearFlowState } from "../utils/sp-config.js";
|
|
4
|
-
import { getSpSession } from "../utils/sp-session.js";
|
|
5
2
|
export default defineEventHandler(async (event) => {
|
|
6
3
|
const query = getQuery(event);
|
|
7
4
|
const { code, state, error, error_description } = query;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { createError, defineEventHandler, getRequestURL, readBody } from "h3";
|
|
2
1
|
import { createAuthorizationURL, discoverIdP } from "@openape/auth";
|
|
3
|
-
import { getSpConfig, saveFlowState } from "../utils/sp-config.js";
|
|
4
2
|
export default defineEventHandler(async (event) => {
|
|
5
3
|
const body = await readBody(event);
|
|
6
4
|
const { spId, openapeUrl } = getSpConfig();
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler, getRequestURL } from "h3";
|
|
2
1
|
import { createSPManifest } from "@openape/auth";
|
|
3
|
-
import { getSpConfig } from "../../utils/sp-config.js";
|
|
4
2
|
export default defineEventHandler((event) => {
|
|
5
3
|
const { spId, spName } = getSpConfig();
|
|
6
4
|
const origin = getRequestURL(event).origin;
|
|
@@ -8,6 +6,6 @@ export default defineEventHandler((event) => {
|
|
|
8
6
|
sp_id: spId,
|
|
9
7
|
name: spName,
|
|
10
8
|
redirect_uris: [`${origin}/api/callback`],
|
|
11
|
-
description: `${spName} \u2014
|
|
9
|
+
description: `${spName} \u2014 OpenAPE Service Provider`
|
|
12
10
|
});
|
|
13
11
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { useSession } from "h3";
|
|
2
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
1
|
const FLOW_COOKIE = "openape-flow";
|
|
4
2
|
export function getSpConfig() {
|
|
5
3
|
const config = useRuntimeConfig();
|
|
6
4
|
return {
|
|
7
5
|
spId: config.openapeSp.spId || "sp.example.com",
|
|
8
6
|
openapeUrl: config.openapeSp.openapeUrl || "",
|
|
9
|
-
spName: config.openapeSp.spName || "
|
|
7
|
+
spName: config.openapeSp.spName || "OpenAPE Service Provider"
|
|
10
8
|
};
|
|
11
9
|
}
|
|
12
10
|
export async function saveFlowState(event, state, flow) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openape/nuxt-auth-sp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"description": "
|
|
6
|
-
"author": "
|
|
4
|
+
"version": "0.1.5",
|
|
5
|
+
"description": "OpenAPE Service Provider Nuxt module \u2014 adds OIDC login via DNS-based IdP discovery",
|
|
6
|
+
"author": "Delta Mind GmbH",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -23,10 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@nuxt/kit": "^3.16.0",
|
|
26
|
-
"@openape/auth": "^0.1.
|
|
27
|
-
"@openape/core": "^0.1.
|
|
28
|
-
"defu": "^6.1.4"
|
|
29
|
-
"h3": "^1.15.0"
|
|
26
|
+
"@openape/auth": "^0.1.2",
|
|
27
|
+
"@openape/core": "^0.1.2",
|
|
28
|
+
"defu": "^6.1.4"
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
32
31
|
"nuxt": "^4.0.0"
|
|
@@ -35,12 +34,5 @@
|
|
|
35
34
|
"@nuxt/module-builder": "^0.8.4",
|
|
36
35
|
"nuxt": "^4.3.1",
|
|
37
36
|
"typescript": "^5.7.0"
|
|
38
|
-
},
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public"
|
|
41
|
-
},
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "https://github.com/openape-ai/nuxt-auth-sp.git"
|
|
45
37
|
}
|
|
46
38
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2025 Patrick Hofmann
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# @openape/nuxt-auth-sp
|
|
2
|
-
|
|
3
|
-
Nuxt module that adds **DDISA-based login** to your application. Users enter their email, the module discovers their Identity Provider via DNS, and handles the full authorization flow — no pre-configured IdP list needed.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @openape/nuxt-auth-sp
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
// nuxt.config.ts
|
|
13
|
-
export default defineNuxtConfig({
|
|
14
|
-
modules: ['@openape/nuxt-auth-sp'],
|
|
15
|
-
|
|
16
|
-
openapeSp: {
|
|
17
|
-
spId: 'sp.example.com',
|
|
18
|
-
spName: 'My Service',
|
|
19
|
-
sessionSecret: 'your-secret-min-32-chars...',
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Configuration
|
|
25
|
-
|
|
26
|
-
| Option | Type | Default | Description |
|
|
27
|
-
|--------|------|---------|-------------|
|
|
28
|
-
| `spId` | `string` | — | **Required.** Service Provider identifier (typically your domain) |
|
|
29
|
-
| `spName` | `string` | `'OpenApe Service Provider'` | Display name shown during authorization |
|
|
30
|
-
| `sessionSecret` | `string` | `'change-me-sp-secret-...'` | Session encryption key |
|
|
31
|
-
| `openapeUrl` | `string` | — | Override IdP URL (bypasses DNS discovery) |
|
|
32
|
-
|
|
33
|
-
## Routes
|
|
34
|
-
|
|
35
|
-
| Method | Path | Description |
|
|
36
|
-
|--------|------|-------------|
|
|
37
|
-
| `POST` | `/api/login` | Start login — `{ email }` → `{ redirectUrl }` |
|
|
38
|
-
| `GET` | `/api/callback` | Handle callback from IdP |
|
|
39
|
-
| `POST` | `/api/logout` | End session |
|
|
40
|
-
| `GET` | `/api/me` | Get current user (`DDISAAssertionClaims`) |
|
|
41
|
-
| `GET` | `/.well-known/sp-manifest.json` | SP manifest for IdP discovery |
|
|
42
|
-
|
|
43
|
-
## Composables
|
|
44
|
-
|
|
45
|
-
### `useOpenApeAuth()`
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
const { user, loading, fetchUser, login, logout } = useOpenApeAuth()
|
|
49
|
-
|
|
50
|
-
// user: Ref<DDISAAssertionClaims | null>
|
|
51
|
-
// DDISAAssertionClaims: { sub, iss, aud, act, iat, exp, nonce, ... }
|
|
52
|
-
|
|
53
|
-
await login('user@example.com') // Redirects to user's IdP
|
|
54
|
-
await logout() // Clears session, navigates to /
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Middleware
|
|
58
|
-
|
|
59
|
-
The module provides an `openape-auth` middleware that protects pages from unauthenticated access.
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
// pages/dashboard.vue
|
|
63
|
-
definePageMeta({
|
|
64
|
-
middleware: 'openape-auth',
|
|
65
|
-
})
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Unauthenticated users are redirected to the login page.
|
|
69
|
-
|
|
70
|
-
## DNS Discovery
|
|
71
|
-
|
|
72
|
-
When a user logs in with `user@example.com`, the module:
|
|
73
|
-
|
|
74
|
-
1. Extracts the domain (`example.com`)
|
|
75
|
-
2. Looks up the `_ddisa.example.com` TXT record
|
|
76
|
-
3. Parses the DDISA record to find the IdP URL
|
|
77
|
-
4. Redirects the user to the IdP's authorization endpoint with PKCE
|
|
78
|
-
5. Handles the callback and validates the signed assertion
|
|
79
|
-
|
|
80
|
-
This means any domain with a DDISA DNS record can authenticate — no pre-registration needed.
|
|
81
|
-
|
|
82
|
-
For details on DNS resolution, see [`@openape/core`](../core).
|
|
83
|
-
|
|
84
|
-
## Quick Start
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
// nuxt.config.ts
|
|
88
|
-
export default defineNuxtConfig({
|
|
89
|
-
modules: ['@openape/nuxt-auth-sp'],
|
|
90
|
-
|
|
91
|
-
openapeSp: {
|
|
92
|
-
spId: 'localhost:3001',
|
|
93
|
-
spName: 'My App',
|
|
94
|
-
sessionSecret: 'at-least-32-characters-long-secret-here',
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
```vue
|
|
100
|
-
<!-- pages/index.vue -->
|
|
101
|
-
<script setup>
|
|
102
|
-
const { user, login, logout } = useOpenApeAuth()
|
|
103
|
-
const email = ref('')
|
|
104
|
-
</script>
|
|
105
|
-
|
|
106
|
-
<template>
|
|
107
|
-
<div v-if="user">
|
|
108
|
-
Logged in as {{ user.sub }}
|
|
109
|
-
<button @click="logout">Logout</button>
|
|
110
|
-
</div>
|
|
111
|
-
<form v-else @submit.prevent="login(email)">
|
|
112
|
-
<input v-model="email" type="email" placeholder="you@example.com" />
|
|
113
|
-
<button type="submit">Login</button>
|
|
114
|
-
</form>
|
|
115
|
-
</template>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
See the [examples](../examples) directory for a fully working SP setup.
|
|
119
|
-
|
|
120
|
-
## License
|
|
121
|
-
|
|
122
|
-
[MIT](./LICENSE)
|