@nuxt-customer-portal/core 0.8.6 → 0.8.9
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/CHANGELOG.md +10 -0
- package/nuxt.config.ts +2 -11
- package/package.json +1 -1
- package/portal.manifest.mjs +1 -1
- package/server/middleware/social-auth-config.ts +8 -0
- package/server/utils/auth.ts +2 -11
- package/shared/social-auth.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @nuxt-customer-portal/core
|
|
2
2
|
|
|
3
|
+
## 0.8.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6cfe8bc: Resolve login and signup provider visibility from the runtime server opt-in flags and credentials, including in prebuilt images, without requiring public Nuxt overrides.
|
|
8
|
+
|
|
9
|
+
## 0.8.8
|
|
10
|
+
|
|
11
|
+
## 0.8.7
|
|
12
|
+
|
|
3
13
|
## 0.8.6
|
|
4
14
|
|
|
5
15
|
## 0.8.5
|
package/nuxt.config.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url'
|
|
2
|
-
import {
|
|
2
|
+
import { socialAuthProviders } from './shared/social-auth'
|
|
3
3
|
|
|
4
4
|
const registrationMode = ['open', 'invitation-only', 'disabled'].includes(process.env.PORTAL_REGISTRATION_MODE || '')
|
|
5
5
|
? (process.env.PORTAL_REGISTRATION_MODE as 'open' | 'invitation-only' | 'disabled')
|
|
6
6
|
: 'open'
|
|
7
|
-
const githubEnabled =
|
|
8
|
-
process.env.PORTAL_GITHUB_ENABLED,
|
|
9
|
-
process.env.GITHUB_CLIENT_ID,
|
|
10
|
-
process.env.GITHUB_CLIENT_SECRET
|
|
11
|
-
)
|
|
12
|
-
const googleEnabled = socialAuthProviderEnabled(
|
|
13
|
-
process.env.PORTAL_GOOGLE_ENABLED,
|
|
14
|
-
process.env.GOOGLE_CLIENT_ID,
|
|
15
|
-
process.env.GOOGLE_CLIENT_SECRET
|
|
16
|
-
)
|
|
7
|
+
const { githubEnabled, googleEnabled } = socialAuthProviders(process.env)
|
|
17
8
|
|
|
18
9
|
export default defineNuxtConfig({
|
|
19
10
|
$meta: { name: 'nuxt-customer-portal-core' },
|
package/package.json
CHANGED
package/portal.manifest.mjs
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineEventHandler } from 'h3'
|
|
2
|
+
import { socialAuthProviders } from '../../shared/social-auth'
|
|
3
|
+
|
|
4
|
+
export default defineEventHandler((event) => {
|
|
5
|
+
// Nitro gives each request its own runtime config. Replace build-time defaults
|
|
6
|
+
// and public overrides with the same availability checks used by Better Auth.
|
|
7
|
+
Object.assign(useRuntimeConfig(event).public.portalAuth, socialAuthProviders(process.env))
|
|
8
|
+
})
|
package/server/utils/auth.ts
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
import { canViewOrganizationDirectory } from '../../shared/feature-registry'
|
|
35
35
|
import { isSystemAdminEmail, parseSystemAdminEmails } from './admin-email-allowlist'
|
|
36
36
|
import { runUserIdentityChangedHooks } from './business-hooks'
|
|
37
|
-
import {
|
|
37
|
+
import { socialAuthProviders } from '../../shared/social-auth'
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Generate an ID in the same format as better-auth uses (nanoid)
|
|
@@ -48,16 +48,7 @@ const portalAuthConfig = useRuntimeConfig().portalAuth
|
|
|
48
48
|
const registrationMode = ['open', 'invitation-only', 'disabled'].includes(process.env.PORTAL_REGISTRATION_MODE || '')
|
|
49
49
|
? process.env.PORTAL_REGISTRATION_MODE
|
|
50
50
|
: portalAuthConfig.registrationMode
|
|
51
|
-
const githubEnabled =
|
|
52
|
-
process.env.PORTAL_GITHUB_ENABLED,
|
|
53
|
-
process.env.GITHUB_CLIENT_ID,
|
|
54
|
-
process.env.GITHUB_CLIENT_SECRET
|
|
55
|
-
)
|
|
56
|
-
const googleEnabled = socialAuthProviderEnabled(
|
|
57
|
-
process.env.PORTAL_GOOGLE_ENABLED,
|
|
58
|
-
process.env.GOOGLE_CLIENT_ID,
|
|
59
|
-
process.env.GOOGLE_CLIENT_SECRET
|
|
60
|
-
)
|
|
51
|
+
const { githubEnabled, googleEnabled } = socialAuthProviders(process.env)
|
|
61
52
|
const systemAdminEmails = isPortalDemo() ? new Set<string>() : parseSystemAdminEmails(process.env.ADMIN_EMAILS)
|
|
62
53
|
|
|
63
54
|
export const auth = betterAuth({
|
package/shared/social-auth.ts
CHANGED
|
@@ -3,3 +3,8 @@ export const socialAuthProviderEnabled = (
|
|
|
3
3
|
clientId: string | undefined,
|
|
4
4
|
clientSecret: string | undefined
|
|
5
5
|
) => enabled === 'true' && Boolean(clientId?.trim()) && Boolean(clientSecret?.trim())
|
|
6
|
+
|
|
7
|
+
export const socialAuthProviders = (env: Record<string, string | undefined>) => ({
|
|
8
|
+
googleEnabled: socialAuthProviderEnabled(env.PORTAL_GOOGLE_ENABLED, env.GOOGLE_CLIENT_ID, env.GOOGLE_CLIENT_SECRET),
|
|
9
|
+
githubEnabled: socialAuthProviderEnabled(env.PORTAL_GITHUB_ENABLED, env.GITHUB_CLIENT_ID, env.GITHUB_CLIENT_SECRET)
|
|
10
|
+
})
|