@openape/nuxt-auth-sp 0.4.1 → 0.5.0
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 +3 -3
- package/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -6
- package/dist/runtime/server/api/callback.get.js +2 -2
- package/dist/runtime/server/api/login.post.js +2 -2
- package/dist/runtime/server/handlers.js +6 -6
- package/dist/runtime/server/routes/well-known/auth.md.get.js +2 -2
- package/dist/runtime/server/routes/well-known/openape.json.get.js +2 -2
- package/dist/runtime/server/routes/well-known/sp-manifest.json.get.js +2 -2
- package/dist/runtime/server/utils/sp-config.d.ts +1 -1
- package/dist/runtime/server/utils/sp-config.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ export default defineNuxtConfig({
|
|
|
14
14
|
modules: ['@openape/nuxt-auth-sp'],
|
|
15
15
|
|
|
16
16
|
openapeSp: {
|
|
17
|
-
|
|
17
|
+
clientId: 'sp.example.com',
|
|
18
18
|
spName: 'My Service',
|
|
19
19
|
sessionSecret: 'your-secret-min-32-chars...',
|
|
20
20
|
},
|
|
@@ -25,7 +25,7 @@ export default defineNuxtConfig({
|
|
|
25
25
|
|
|
26
26
|
| Option | Type | Default | Description |
|
|
27
27
|
|--------|------|---------|-------------|
|
|
28
|
-
| `
|
|
28
|
+
| `clientId` | `string` | — | **Required.** Service Provider identifier (typically your domain) |
|
|
29
29
|
| `spName` | `string` | `'OpenApe Service Provider'` | Display name shown during authorization |
|
|
30
30
|
| `sessionSecret` | `string` | `'change-me-sp-secret-...'` | Session encryption key |
|
|
31
31
|
| `openapeUrl` | `string` | — | Override IdP URL (bypasses DNS discovery) |
|
|
@@ -89,7 +89,7 @@ export default defineNuxtConfig({
|
|
|
89
89
|
modules: ['@openape/nuxt-auth-sp'],
|
|
90
90
|
|
|
91
91
|
openapeSp: {
|
|
92
|
-
|
|
92
|
+
clientId: 'localhost:3001',
|
|
93
93
|
spName: 'My App',
|
|
94
94
|
sessionSecret: 'at-least-32-characters-long-secret-here',
|
|
95
95
|
},
|
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -9,7 +9,7 @@ const module$1 = defineNuxtModule({
|
|
|
9
9
|
configKey: "openapeSp"
|
|
10
10
|
},
|
|
11
11
|
defaults: {
|
|
12
|
-
|
|
12
|
+
clientId: "",
|
|
13
13
|
spName: "OpenApe Service Provider",
|
|
14
14
|
sessionSecret: "change-me-sp-secret-at-least-32-chars-long",
|
|
15
15
|
openapeUrl: "",
|
|
@@ -29,10 +29,10 @@ const module$1 = defineNuxtModule({
|
|
|
29
29
|
config.sessionSecret = crypto.randomUUID() + crypto.randomUUID();
|
|
30
30
|
logger.info("Auto-generated sessionSecret for dev mode");
|
|
31
31
|
}
|
|
32
|
-
if (!config.
|
|
32
|
+
if (!config.clientId) {
|
|
33
33
|
const port = nuxt.options.devServer?.port || 3e3;
|
|
34
|
-
config.
|
|
35
|
-
logger.info(`Auto-derived
|
|
34
|
+
config.clientId = `localhost:${port}`;
|
|
35
|
+
logger.info(`Auto-derived clientId: ${config.clientId}`);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
if (!nuxt.options.dev) {
|
|
@@ -40,8 +40,8 @@ const module$1 = defineNuxtModule({
|
|
|
40
40
|
if (config.sessionSecret === "change-me-sp-secret-at-least-32-chars-long") {
|
|
41
41
|
logger.warn("Using default sessionSecret in production! Set NUXT_OPENAPE_SP_SESSION_SECRET.");
|
|
42
42
|
}
|
|
43
|
-
if (!config.
|
|
44
|
-
logger.warn("
|
|
43
|
+
if (!config.clientId) {
|
|
44
|
+
logger.warn("clientId is empty in production! Set openapeSp.clientId or NUXT_OPENAPE_SP_CLIENT_ID.");
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
addServerImportsDir(resolve("./runtime/server/utils"));
|
|
@@ -5,7 +5,7 @@ import { getSpSession } from "../utils/sp-session.js";
|
|
|
5
5
|
export default defineEventHandler(async (event) => {
|
|
6
6
|
const query = getQuery(event);
|
|
7
7
|
const { code, state, error, error_description } = query;
|
|
8
|
-
const {
|
|
8
|
+
const { clientId } = getSpConfig();
|
|
9
9
|
const origin = getRequestURL(event).origin;
|
|
10
10
|
const redirectUri = `${origin}/api/callback`;
|
|
11
11
|
if (error) {
|
|
@@ -24,7 +24,7 @@ export default defineEventHandler(async (event) => {
|
|
|
24
24
|
code,
|
|
25
25
|
state,
|
|
26
26
|
flowState,
|
|
27
|
-
|
|
27
|
+
clientId,
|
|
28
28
|
redirectUri
|
|
29
29
|
});
|
|
30
30
|
clearFlowState(event);
|
|
@@ -3,7 +3,7 @@ import { createAuthorizationURL, discoverIdP } from "@openape/auth";
|
|
|
3
3
|
import { getSpConfig, saveFlowState } from "../utils/sp-config.js";
|
|
4
4
|
export default defineEventHandler(async (event) => {
|
|
5
5
|
const body = await readBody(event);
|
|
6
|
-
const {
|
|
6
|
+
const { clientId, openapeUrl, fallbackIdpUrl } = getSpConfig();
|
|
7
7
|
const origin = getRequestURL(event).origin;
|
|
8
8
|
const redirectUri = `${origin}/api/callback`;
|
|
9
9
|
if (!body?.email || !body.email.includes("@")) {
|
|
@@ -24,7 +24,7 @@ export default defineEventHandler(async (event) => {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
const { url, flowState } = await createAuthorizationURL(idpConfig, {
|
|
27
|
-
|
|
27
|
+
clientId,
|
|
28
28
|
redirectUri,
|
|
29
29
|
email
|
|
30
30
|
});
|
|
@@ -4,7 +4,7 @@ import { getSpConfig, saveFlowState, getFlowState, clearFlowState } from "./util
|
|
|
4
4
|
export function defineOpenApeLoginHandler(options) {
|
|
5
5
|
return defineEventHandler(async (event) => {
|
|
6
6
|
const body = await readBody(event);
|
|
7
|
-
const {
|
|
7
|
+
const { clientId, openapeUrl, fallbackIdpUrl } = getSpConfig();
|
|
8
8
|
const origin = getRequestURL(event).origin;
|
|
9
9
|
const redirectUri = `${origin}${options.callbackPath}`;
|
|
10
10
|
if (!body?.email || !body.email.includes("@")) {
|
|
@@ -25,7 +25,7 @@ export function defineOpenApeLoginHandler(options) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
const { url, flowState } = await createAuthorizationURL(idpConfig, {
|
|
28
|
-
|
|
28
|
+
clientId,
|
|
29
29
|
redirectUri,
|
|
30
30
|
email
|
|
31
31
|
});
|
|
@@ -37,7 +37,7 @@ export function defineOpenApeCallbackHandler(options) {
|
|
|
37
37
|
return defineEventHandler(async (event) => {
|
|
38
38
|
const query = getQuery(event);
|
|
39
39
|
const { code, state, error, error_description } = query;
|
|
40
|
-
const {
|
|
40
|
+
const { clientId } = getSpConfig();
|
|
41
41
|
const origin = getRequestURL(event).origin;
|
|
42
42
|
if (error) {
|
|
43
43
|
const msg = error_description || error;
|
|
@@ -70,7 +70,7 @@ export function defineOpenApeCallbackHandler(options) {
|
|
|
70
70
|
code,
|
|
71
71
|
state,
|
|
72
72
|
flowState,
|
|
73
|
-
|
|
73
|
+
clientId,
|
|
74
74
|
redirectUri
|
|
75
75
|
});
|
|
76
76
|
await clearFlowState(event);
|
|
@@ -88,10 +88,10 @@ export function defineOpenApeCallbackHandler(options) {
|
|
|
88
88
|
}
|
|
89
89
|
export function defineOpenApeSPManifestHandler(options) {
|
|
90
90
|
return defineEventHandler((event) => {
|
|
91
|
-
const {
|
|
91
|
+
const { clientId, spName } = getSpConfig();
|
|
92
92
|
const origin = getRequestURL(event).origin;
|
|
93
93
|
return createSPManifest({
|
|
94
|
-
|
|
94
|
+
client_id: clientId,
|
|
95
95
|
name: spName,
|
|
96
96
|
redirect_uris: [`${origin}${options.callbackPath}`],
|
|
97
97
|
description: options.description || `${spName} \u2014 OpenApe Service Provider`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler, getRequestURL, setResponseHeader } from "h3";
|
|
2
2
|
import { getSpConfig } from "../../utils/sp-config.js";
|
|
3
3
|
export default defineEventHandler((event) => {
|
|
4
|
-
const {
|
|
4
|
+
const { clientId, spName, fallbackIdpUrl } = getSpConfig();
|
|
5
5
|
const origin = getRequestURL(event).origin;
|
|
6
6
|
setResponseHeader(event, "Content-Type", "text/markdown; charset=utf-8");
|
|
7
7
|
return `# Authentication \u2014 ${spName}
|
|
@@ -10,7 +10,7 @@ export default defineEventHandler((event) => {
|
|
|
10
10
|
DDISA v1 (DNS-Discoverable Identity & Service Authorization)
|
|
11
11
|
|
|
12
12
|
## Service Provider
|
|
13
|
-
- **SP ID:** \`${
|
|
13
|
+
- **SP ID:** \`${clientId}\`
|
|
14
14
|
- **Origin:** \`${origin}\`
|
|
15
15
|
|
|
16
16
|
## Endpoints
|
|
@@ -3,7 +3,7 @@ import { useRuntimeConfig } from "nitropack/runtime";
|
|
|
3
3
|
import { getSpConfig } from "../../utils/sp-config.js";
|
|
4
4
|
export default defineEventHandler((event) => {
|
|
5
5
|
const config = useRuntimeConfig();
|
|
6
|
-
const {
|
|
6
|
+
const { clientId, spName } = getSpConfig();
|
|
7
7
|
const origin = getRequestURL(event).origin;
|
|
8
8
|
const manifest = config.openapeSp.manifest;
|
|
9
9
|
setResponseHeader(event, "Access-Control-Allow-Origin", "*");
|
|
@@ -16,7 +16,7 @@ export default defineEventHandler((event) => {
|
|
|
16
16
|
...manifest?.service || {}
|
|
17
17
|
},
|
|
18
18
|
auth: {
|
|
19
|
-
ddisa_domain:
|
|
19
|
+
ddisa_domain: clientId,
|
|
20
20
|
supported_methods: ["ddisa"],
|
|
21
21
|
...manifest?.auth || {}
|
|
22
22
|
},
|
|
@@ -2,10 +2,10 @@ import { defineEventHandler, getRequestURL } from "h3";
|
|
|
2
2
|
import { createSPManifest } from "@openape/auth";
|
|
3
3
|
import { getSpConfig } from "../../utils/sp-config.js";
|
|
4
4
|
export default defineEventHandler((event) => {
|
|
5
|
-
const {
|
|
5
|
+
const { clientId, spName } = getSpConfig();
|
|
6
6
|
const origin = getRequestURL(event).origin;
|
|
7
7
|
return createSPManifest({
|
|
8
|
-
|
|
8
|
+
client_id: clientId,
|
|
9
9
|
name: spName,
|
|
10
10
|
redirect_uris: [`${origin}/api/callback`],
|
|
11
11
|
description: `${spName} \u2014 OpenApe Service Provider`
|
|
@@ -4,7 +4,7 @@ const FLOW_COOKIE = "openape-flow";
|
|
|
4
4
|
export function getSpConfig() {
|
|
5
5
|
const config = useRuntimeConfig();
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
clientId: (config.openapeSp.clientId || "sp.example.com").trim(),
|
|
8
8
|
openapeUrl: (config.openapeSp.openapeUrl || "").trim(),
|
|
9
9
|
spName: (config.openapeSp.spName || "OpenApe Service Provider").trim(),
|
|
10
10
|
fallbackIdpUrl: (config.openapeSp.fallbackIdpUrl || "https://id.openape.at").trim()
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openape/nuxt-auth-sp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"description": "OpenAPE Service Provider Nuxt module — adds OIDC login via DNS-based IdP discovery",
|
|
6
6
|
"author": "Delta Mind GmbH",
|
|
7
7
|
"license": "AGPL-3.0-or-later",
|