@phila/sso-nuxt 0.0.1 → 0.0.2
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.ts +9 -0
- package/dist/module.js +49 -0
- package/dist/module.js.map +1 -0
- package/dist/runtime/middleware.auth.d.ts +2 -0
- package/dist/runtime/middleware.auth.js +11 -0
- package/dist/runtime/middleware.auth.js.map +1 -0
- package/dist/runtime/plugin.client.d.ts +2 -0
- package/dist/runtime/plugin.client.js +24 -0
- package/dist/runtime/plugin.client.js.map +1 -0
- package/package.json +25 -6
- package/CHANGELOG.md +0 -7
- package/src/module.ts +0 -84
- package/src/runtime/middleware.auth.ts +0 -16
- package/src/runtime/plugin.client.ts +0 -25
- package/tsconfig.json +0 -15
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ModuleOptions {
|
|
2
|
+
globalAuth?: boolean;
|
|
3
|
+
loginPath?: string;
|
|
4
|
+
excludePaths?: string[];
|
|
5
|
+
signInPolicy?: string;
|
|
6
|
+
resetPasswordPolicy?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import('nuxt/schema').NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
9
|
+
export default _default;
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, installModule, extendViteConfig, addPlugin, addImports, addRouteMiddleware } from "@nuxt/kit";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { defu } from "defu";
|
|
5
|
+
const __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const philaIdentityRoot = resolve(__dirname$1, "../../..");
|
|
7
|
+
defineNuxtModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "@phila/sso-nuxt",
|
|
10
|
+
configKey: "sso"
|
|
11
|
+
},
|
|
12
|
+
defaults: {
|
|
13
|
+
globalAuth: true,
|
|
14
|
+
loginPath: "/login",
|
|
15
|
+
excludePaths: ["/logout"],
|
|
16
|
+
signInPolicy: "B2C_1A_AD_SIGNIN_ONLY",
|
|
17
|
+
resetPasswordPolicy: "B2C_1A_PASSWORDRESET"
|
|
18
|
+
},
|
|
19
|
+
async setup(options, nuxt) {
|
|
20
|
+
const resolver = createResolver(import.meta.url);
|
|
21
|
+
await installModule("@pinia/nuxt");
|
|
22
|
+
nuxt.options.build.transpile.push("@phila/sso-core", "@phila/sso-vue");
|
|
23
|
+
extendViteConfig((config) => {
|
|
24
|
+
config.server = config.server ?? {};
|
|
25
|
+
config.server.fs = config.server.fs ?? {};
|
|
26
|
+
config.server.fs.allow = [...config.server.fs.allow ?? [], philaIdentityRoot];
|
|
27
|
+
});
|
|
28
|
+
nuxt.options.runtimeConfig.public = defu(nuxt.options.runtimeConfig.public, {
|
|
29
|
+
ssoClientId: "",
|
|
30
|
+
ssoRedirectUri: "http://localhost:3000",
|
|
31
|
+
ssoTenant: "PhilaB2CDev",
|
|
32
|
+
ssoAuthorityDomain: "PhilaB2CDev.b2clogin.com",
|
|
33
|
+
ssoSignInPolicy: options.signInPolicy,
|
|
34
|
+
ssoResetPasswordPolicy: options.resetPasswordPolicy,
|
|
35
|
+
ssoLoginPath: options.loginPath,
|
|
36
|
+
ssoExcludePaths: options.excludePaths
|
|
37
|
+
});
|
|
38
|
+
addPlugin({ src: resolver.resolve("./runtime/plugin.client"), mode: "client" });
|
|
39
|
+
addImports({ name: "useAuth", as: "useAuth", from: "@phila/sso-vue" });
|
|
40
|
+
if (options.globalAuth) {
|
|
41
|
+
addRouteMiddleware({
|
|
42
|
+
name: "auth",
|
|
43
|
+
path: resolver.resolve("./runtime/middleware.auth"),
|
|
44
|
+
global: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["// ABOUTME: Nuxt module that wires up phila-identity SSO with zero app boilerplate\n// ABOUTME: Installs pinia, registers the client plugin, auto-imports useAuth, and optionally guards routes\n\nimport {\n defineNuxtModule,\n addPlugin,\n addImports,\n addRouteMiddleware,\n installModule,\n createResolver,\n extendViteConfig,\n} from \"@nuxt/kit\";\nimport { fileURLToPath } from \"node:url\";\nimport { dirname, resolve } from \"node:path\";\nimport { defu } from \"defu\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n// packages/sso-nuxt/src → packages/sso-nuxt → packages → phila-identity\nconst philaIdentityRoot = resolve(__dirname, \"../../..\");\n\nexport interface ModuleOptions {\n globalAuth?: boolean;\n loginPath?: string;\n excludePaths?: string[];\n signInPolicy?: string;\n resetPasswordPolicy?: string;\n}\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: \"@phila/sso-nuxt\",\n configKey: \"sso\",\n },\n defaults: {\n globalAuth: true,\n loginPath: \"/login\",\n excludePaths: [\"/logout\"],\n signInPolicy: \"B2C_1A_AD_SIGNIN_ONLY\",\n resetPasswordPolicy: \"B2C_1A_PASSWORDRESET\",\n },\n async setup(options, nuxt) {\n const resolver = createResolver(import.meta.url);\n\n // 1. Install @pinia/nuxt so apps don't need to list it explicitly\n await installModule(\"@pinia/nuxt\");\n\n // 2. Transpile local file: linked packages so Vite/SSR can process them\n nuxt.options.build.transpile.push(\"@phila/sso-core\", \"@phila/sso-vue\");\n\n // 3. Allow Vite dev server to serve files from phila-identity source tree\n extendViteConfig(config => {\n config.server = config.server ?? {};\n config.server.fs = config.server.fs ?? {};\n config.server.fs.allow = [...(config.server.fs.allow ?? []), philaIdentityRoot];\n });\n\n // 4 & 5. Declare SSO keys in runtimeConfig.public (env vars override at runtime)\n nuxt.options.runtimeConfig.public = defu(nuxt.options.runtimeConfig.public, {\n ssoClientId: \"\",\n ssoRedirectUri: \"http://localhost:3000\",\n ssoTenant: \"PhilaB2CDev\",\n ssoAuthorityDomain: \"PhilaB2CDev.b2clogin.com\",\n ssoSignInPolicy: options.signInPolicy,\n ssoResetPasswordPolicy: options.resetPasswordPolicy,\n ssoLoginPath: options.loginPath,\n ssoExcludePaths: options.excludePaths,\n });\n\n // 6. Register client-only plugin that initialises the B2C auth client\n addPlugin({ src: resolver.resolve(\"./runtime/plugin.client\"), mode: \"client\" });\n\n // 7. Auto-import useAuth so components don't need an explicit import\n addImports({ name: \"useAuth\", as: \"useAuth\", from: \"@phila/sso-vue\" });\n\n // 8. Optionally register global route guard\n if (options.globalAuth) {\n addRouteMiddleware({\n name: \"auth\",\n path: resolver.resolve(\"./runtime/middleware.auth\"),\n global: true,\n });\n }\n },\n});\n"],"names":["__dirname"],"mappings":";;;;AAgBA,MAAMA,cAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,MAAM,oBAAoB,QAAQA,aAAW,UAAU;AAUxC,iBAAgC;AAAA,EAC7C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,WAAW;AAAA,EAAA;AAAA,EAEb,UAAU;AAAA,IACR,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,cAAc,CAAC,SAAS;AAAA,IACxB,cAAc;AAAA,IACd,qBAAqB;AAAA,EAAA;AAAA,EAEvB,MAAM,MAAM,SAAS,MAAM;AACzB,UAAM,WAAW,eAAe,YAAY,GAAG;AAG/C,UAAM,cAAc,aAAa;AAGjC,SAAK,QAAQ,MAAM,UAAU,KAAK,mBAAmB,gBAAgB;AAGrE,qBAAiB,CAAA,WAAU;AACzB,aAAO,SAAS,OAAO,UAAU,CAAA;AACjC,aAAO,OAAO,KAAK,OAAO,OAAO,MAAM,CAAA;AACvC,aAAO,OAAO,GAAG,QAAQ,CAAC,GAAI,OAAO,OAAO,GAAG,SAAS,CAAA,GAAK,iBAAiB;AAAA,IAChF,CAAC;AAGD,SAAK,QAAQ,cAAc,SAAS,KAAK,KAAK,QAAQ,cAAc,QAAQ;AAAA,MAC1E,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB,iBAAiB,QAAQ;AAAA,MACzB,wBAAwB,QAAQ;AAAA,MAChC,cAAc,QAAQ;AAAA,MACtB,iBAAiB,QAAQ;AAAA,IAAA,CAC1B;AAGD,cAAU,EAAE,KAAK,SAAS,QAAQ,yBAAyB,GAAG,MAAM,UAAU;AAG9E,eAAW,EAAE,MAAM,WAAW,IAAI,WAAW,MAAM,kBAAkB;AAGrE,QAAI,QAAQ,YAAY;AACtB,yBAAmB;AAAA,QACjB,MAAM;AAAA,QACN,MAAM,SAAS,QAAQ,2BAA2B;AAAA,QAClD,QAAQ;AAAA,MAAA,CACT;AAAA,IACH;AAAA,EACF;AACF,CAAC;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineNuxtRouteMiddleware, useRuntimeConfig, navigateTo } from "nuxt/app";
|
|
2
|
+
import { useSSOStore } from "@phila/sso-vue";
|
|
3
|
+
defineNuxtRouteMiddleware((to) => {
|
|
4
|
+
const config = useRuntimeConfig().public;
|
|
5
|
+
const store = useSSOStore();
|
|
6
|
+
if (!store.authReady) return;
|
|
7
|
+
const excluded = [config.ssoLoginPath, ...config.ssoExcludePaths];
|
|
8
|
+
if (excluded.some((p) => to.path.startsWith(p))) return;
|
|
9
|
+
if (!store.isAuthenticated) return navigateTo({ path: config.ssoLoginPath });
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=middleware.auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.auth.js","sources":["../../src/runtime/middleware.auth.ts"],"sourcesContent":["// ABOUTME: Route middleware registered by @phila/sso-nuxt module\n// ABOUTME: Redirects unauthenticated users to the configured login path\nimport { defineNuxtRouteMiddleware, useRuntimeConfig, navigateTo } from \"nuxt/app\";\nimport { useSSOStore } from \"@phila/sso-vue\";\n\nexport default defineNuxtRouteMiddleware(to => {\n const config = useRuntimeConfig().public;\n const store = useSSOStore();\n\n // Don't redirect while auth is still initialising\n if (!store.authReady) return;\n\n const excluded = [config.ssoLoginPath as string, ...(config.ssoExcludePaths as string[])];\n if (excluded.some(p => to.path.startsWith(p))) return;\n\n if (!store.isAuthenticated) return navigateTo({ path: config.ssoLoginPath as string });\n});\n"],"names":[],"mappings":";;AAKe,0BAA0B,CAAA,OAAM;AAC7C,QAAM,SAAS,mBAAmB;AAClC,QAAM,QAAQ,YAAA;AAGd,MAAI,CAAC,MAAM,UAAW;AAEtB,QAAM,WAAW,CAAC,OAAO,cAAwB,GAAI,OAAO,eAA4B;AACxF,MAAI,SAAS,KAAK,CAAA,MAAK,GAAG,KAAK,WAAW,CAAC,CAAC,EAAG;AAE/C,MAAI,CAAC,MAAM,gBAAiB,QAAO,WAAW,EAAE,MAAM,OAAO,cAAwB;AACvF,CAAC;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
|
|
2
|
+
import { createSSOPlugin } from "@phila/sso-vue";
|
|
3
|
+
import { B2CProvider } from "@phila/sso-core";
|
|
4
|
+
defineNuxtPlugin((nuxtApp) => {
|
|
5
|
+
const config = useRuntimeConfig().public;
|
|
6
|
+
const plugin = createSSOPlugin({
|
|
7
|
+
clientConfig: {
|
|
8
|
+
provider: new B2CProvider({
|
|
9
|
+
clientId: config.ssoClientId,
|
|
10
|
+
b2cEnvironment: config.ssoTenant,
|
|
11
|
+
authorityDomain: config.ssoAuthorityDomain,
|
|
12
|
+
redirectUri: config.ssoRedirectUri,
|
|
13
|
+
policies: {
|
|
14
|
+
signUpSignIn: config.ssoSignInPolicy,
|
|
15
|
+
signInOnly: config.ssoSignInPolicy,
|
|
16
|
+
resetPassword: config.ssoResetPasswordPolicy
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
debug: import.meta.dev
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
nuxtApp.vueApp.use(plugin);
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=plugin.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.client.js","sources":["../../src/runtime/plugin.client.ts"],"sourcesContent":["// ABOUTME: Client-only Nuxt plugin registered by @phila/sso-nuxt module\n// ABOUTME: Initializes Azure AD B2C authentication on the Nuxt app instance\nimport { defineNuxtPlugin, useRuntimeConfig } from \"nuxt/app\";\nimport { createSSOPlugin } from \"@phila/sso-vue\";\nimport { B2CProvider } from \"@phila/sso-core\";\n\nexport default defineNuxtPlugin(nuxtApp => {\n const config = useRuntimeConfig().public;\n const plugin = createSSOPlugin({\n clientConfig: {\n provider: new B2CProvider({\n clientId: config.ssoClientId as string,\n b2cEnvironment: config.ssoTenant as string,\n authorityDomain: config.ssoAuthorityDomain as string,\n redirectUri: config.ssoRedirectUri as string,\n policies: {\n signUpSignIn: config.ssoSignInPolicy as string,\n signInOnly: config.ssoSignInPolicy as string,\n resetPassword: config.ssoResetPasswordPolicy as string,\n },\n }),\n debug: import.meta.dev,\n },\n });\n nuxtApp.vueApp.use(plugin);\n});\n"],"names":[],"mappings":";;;AAMe,iBAAiB,CAAA,YAAW;AACzC,QAAM,SAAS,mBAAmB;AAClC,QAAM,SAAS,gBAAgB;AAAA,IAC7B,cAAc;AAAA,MACZ,UAAU,IAAI,YAAY;AAAA,QACxB,UAAU,OAAO;AAAA,QACjB,gBAAgB,OAAO;AAAA,QACvB,iBAAiB,OAAO;AAAA,QACxB,aAAa,OAAO;AAAA,QACpB,UAAU;AAAA,UACR,cAAc,OAAO;AAAA,UACrB,YAAY,OAAO;AAAA,UACnB,eAAe,OAAO;AAAA,QAAA;AAAA,MACxB,CACD;AAAA,MACD,OAAO,YAAY;AAAA,IAAA;AAAA,EACrB,CACD;AACD,UAAQ,OAAO,IAAI,MAAM;AAC3B,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phila/sso-nuxt",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
|
-
".":
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/module.d.ts",
|
|
8
|
+
"import": "./dist/module.js"
|
|
9
|
+
}
|
|
7
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
8
14
|
"dependencies": {
|
|
9
15
|
"@nuxt/kit": "^3.0.0",
|
|
10
|
-
"
|
|
11
|
-
"@phila/sso-
|
|
12
|
-
"
|
|
16
|
+
"defu": "^6.0.0",
|
|
17
|
+
"@phila/sso-core": "0.0.2",
|
|
18
|
+
"@phila/sso-vue": "0.0.2"
|
|
13
19
|
},
|
|
14
20
|
"peerDependencies": {
|
|
15
21
|
"nuxt": "^3.0.0"
|
|
16
22
|
},
|
|
17
23
|
"devDependencies": {
|
|
24
|
+
"@types/node": "^24.0.0",
|
|
18
25
|
"nuxt": "^3.17.0",
|
|
19
|
-
"typescript": "^5.9.3"
|
|
26
|
+
"typescript": "^5.9.3",
|
|
27
|
+
"vite": "^7.0.6",
|
|
28
|
+
"vite-plugin-dts": "^3.9.1"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "vite build",
|
|
32
|
+
"dev": "vite build --watch",
|
|
33
|
+
"lint": "eslint src/**/*.ts",
|
|
34
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
35
|
+
"test": "vitest run --passWithNoTests",
|
|
36
|
+
"test:watch": "vitest",
|
|
37
|
+
"type-check": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist"
|
|
20
39
|
}
|
|
21
40
|
}
|
package/CHANGELOG.md
DELETED
package/src/module.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// ABOUTME: Nuxt module that wires up phila-identity SSO with zero app boilerplate
|
|
2
|
-
// ABOUTME: Installs pinia, registers the client plugin, auto-imports useAuth, and optionally guards routes
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
defineNuxtModule,
|
|
6
|
-
addPlugin,
|
|
7
|
-
addImports,
|
|
8
|
-
addRouteMiddleware,
|
|
9
|
-
installModule,
|
|
10
|
-
createResolver,
|
|
11
|
-
extendViteConfig,
|
|
12
|
-
} from "@nuxt/kit";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
|
-
import { dirname, resolve } from "node:path";
|
|
15
|
-
import { defu } from "defu";
|
|
16
|
-
|
|
17
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
// packages/sso-nuxt/src → packages/sso-nuxt → packages → phila-identity
|
|
19
|
-
const philaIdentityRoot = resolve(__dirname, "../../..");
|
|
20
|
-
|
|
21
|
-
export interface ModuleOptions {
|
|
22
|
-
globalAuth?: boolean;
|
|
23
|
-
loginPath?: string;
|
|
24
|
-
excludePaths?: string[];
|
|
25
|
-
signInPolicy?: string;
|
|
26
|
-
resetPasswordPolicy?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default defineNuxtModule<ModuleOptions>({
|
|
30
|
-
meta: {
|
|
31
|
-
name: "@phila/sso-nuxt",
|
|
32
|
-
configKey: "sso",
|
|
33
|
-
},
|
|
34
|
-
defaults: {
|
|
35
|
-
globalAuth: true,
|
|
36
|
-
loginPath: "/login",
|
|
37
|
-
excludePaths: ["/logout"],
|
|
38
|
-
signInPolicy: "B2C_1A_AD_SIGNIN_ONLY",
|
|
39
|
-
resetPasswordPolicy: "B2C_1A_PASSWORDRESET",
|
|
40
|
-
},
|
|
41
|
-
async setup(options, nuxt) {
|
|
42
|
-
const resolver = createResolver(import.meta.url);
|
|
43
|
-
|
|
44
|
-
// 1. Install @pinia/nuxt so apps don't need to list it explicitly
|
|
45
|
-
await installModule("@pinia/nuxt");
|
|
46
|
-
|
|
47
|
-
// 2. Transpile local file: linked packages so Vite/SSR can process them
|
|
48
|
-
nuxt.options.build.transpile.push("@phila/sso-core", "@phila/sso-vue");
|
|
49
|
-
|
|
50
|
-
// 3. Allow Vite dev server to serve files from phila-identity source tree
|
|
51
|
-
extendViteConfig(config => {
|
|
52
|
-
config.server = config.server ?? {};
|
|
53
|
-
config.server.fs = config.server.fs ?? {};
|
|
54
|
-
config.server.fs.allow = [...(config.server.fs.allow ?? []), philaIdentityRoot];
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// 4 & 5. Declare SSO keys in runtimeConfig.public (env vars override at runtime)
|
|
58
|
-
nuxt.options.runtimeConfig.public = defu(nuxt.options.runtimeConfig.public, {
|
|
59
|
-
ssoClientId: "",
|
|
60
|
-
ssoRedirectUri: "http://localhost:3000",
|
|
61
|
-
ssoTenant: "PhilaB2CDev",
|
|
62
|
-
ssoAuthorityDomain: "PhilaB2CDev.b2clogin.com",
|
|
63
|
-
ssoSignInPolicy: options.signInPolicy,
|
|
64
|
-
ssoResetPasswordPolicy: options.resetPasswordPolicy,
|
|
65
|
-
ssoLoginPath: options.loginPath,
|
|
66
|
-
ssoExcludePaths: options.excludePaths,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// 6. Register client-only plugin that initialises the B2C auth client
|
|
70
|
-
addPlugin({ src: resolver.resolve("./runtime/plugin.client"), mode: "client" });
|
|
71
|
-
|
|
72
|
-
// 7. Auto-import useAuth so components don't need an explicit import
|
|
73
|
-
addImports({ name: "useAuth", as: "useAuth", from: "@phila/sso-vue" });
|
|
74
|
-
|
|
75
|
-
// 8. Optionally register global route guard
|
|
76
|
-
if (options.globalAuth) {
|
|
77
|
-
addRouteMiddleware({
|
|
78
|
-
name: "auth",
|
|
79
|
-
path: resolver.resolve("./runtime/middleware.auth"),
|
|
80
|
-
global: true,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// ABOUTME: Route middleware registered by @phila/sso-nuxt module
|
|
2
|
-
// ABOUTME: Redirects unauthenticated users to the configured login path
|
|
3
|
-
import { useSSOStore } from "@phila/sso-vue";
|
|
4
|
-
|
|
5
|
-
export default defineNuxtRouteMiddleware(to => {
|
|
6
|
-
const config = useRuntimeConfig().public;
|
|
7
|
-
const store = useSSOStore();
|
|
8
|
-
|
|
9
|
-
// Don't redirect while auth is still initialising
|
|
10
|
-
if (!store.authReady) return;
|
|
11
|
-
|
|
12
|
-
const excluded = [config.ssoLoginPath as string, ...(config.ssoExcludePaths as string[])];
|
|
13
|
-
if (excluded.some(p => to.path.startsWith(p))) return;
|
|
14
|
-
|
|
15
|
-
if (!store.isAuthenticated) return navigateTo({ path: config.ssoLoginPath as string });
|
|
16
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// ABOUTME: Client-only Nuxt plugin registered by @phila/sso-nuxt module
|
|
2
|
-
// ABOUTME: Initializes Azure AD B2C authentication on the Nuxt app instance
|
|
3
|
-
import { createSSOPlugin } from "@phila/sso-vue";
|
|
4
|
-
import { B2CProvider } from "@phila/sso-core";
|
|
5
|
-
|
|
6
|
-
export default defineNuxtPlugin(nuxtApp => {
|
|
7
|
-
const config = useRuntimeConfig().public;
|
|
8
|
-
const plugin = createSSOPlugin({
|
|
9
|
-
clientConfig: {
|
|
10
|
-
provider: new B2CProvider({
|
|
11
|
-
clientId: config.ssoClientId as string,
|
|
12
|
-
b2cEnvironment: config.ssoTenant as string,
|
|
13
|
-
authorityDomain: config.ssoAuthorityDomain as string,
|
|
14
|
-
redirectUri: config.ssoRedirectUri as string,
|
|
15
|
-
policies: {
|
|
16
|
-
signUpSignIn: config.ssoSignInPolicy as string,
|
|
17
|
-
signInOnly: config.ssoSignInPolicy as string,
|
|
18
|
-
resetPassword: config.ssoResetPasswordPolicy as string,
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
debug: import.meta.dev,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
nuxtApp.vueApp.use(plugin);
|
|
25
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"skipLibCheck": true,
|
|
7
|
-
"moduleResolution": "bundler",
|
|
8
|
-
"allowImportingTsExtensions": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"isolatedModules": true,
|
|
11
|
-
"noEmit": true,
|
|
12
|
-
"strict": true
|
|
13
|
-
},
|
|
14
|
-
"include": ["src/**/*.ts"]
|
|
15
|
-
}
|