From 2051c656720d30e2f75d66ab9192854ea76ebe63 Mon Sep 17 00:00:00 2001 From: Thomas Boutell Date: Thu, 3 Jul 2025 15:22:26 -0400 Subject: [PATCH] validation that passport bridge 1.5.0-beta.1 does not break more typical passport strategies configured the old fashioned way --- apos.vite.config.js | 13 ++++++++ app.js | 4 ++- .../@apostrophecms/home-page/views/page.html | 2 +- .../@apostrophecms/passport-bridge/index.js | 30 +++++++++++++++++++ package.json | 4 ++- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 apos.vite.config.js create mode 100644 modules/@apostrophecms/passport-bridge/index.js diff --git a/apos.vite.config.js b/apos.vite.config.js new file mode 100644 index 00000000..ec5f193b --- /dev/null +++ b/apos.vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from '@apostrophecms/vite/vite'; + +export default defineConfig({ + server: { + hmr: { + protocol: 'wss', + host: 'b75daf165449.ngrok.app', + }, + origin: 'https://b75daf165449.ngrok.app', + cors: true, + strictPort: true + } +}); \ No newline at end of file diff --git a/app.js b/app.js index 9586c13c..af0b206e 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,7 @@ import apostrophe from 'apostrophe'; apostrophe({ root: import.meta, shortName: 'a4-boilerplate', + baseUrl: 'https://b75daf165449.ngrok.app', modules: { // Apostrophe module configuration // ******************************* @@ -34,6 +35,7 @@ apostrophe({ // use vite for asset bundling and hot module reloading '@apostrophecms/vite': {}, // The project's first custom page type. - 'default-page': {} + 'default-page': {}, + '@apostrophecms/passport-bridge': {} } }); diff --git a/modules/@apostrophecms/home-page/views/page.html b/modules/@apostrophecms/home-page/views/page.html index 58d5f491..d2503746 100644 --- a/modules/@apostrophecms/home-page/views/page.html +++ b/modules/@apostrophecms/home-page/views/page.html @@ -8,7 +8,7 @@ {% block main %}

- Welcome to ApostropheCMS + Welcome to ApostropheCMS, {{ data.user.title }}

{% if not data.user %} {# Message only for logged out users. #} diff --git a/modules/@apostrophecms/passport-bridge/index.js b/modules/@apostrophecms/passport-bridge/index.js new file mode 100644 index 00000000..7b2419e6 --- /dev/null +++ b/modules/@apostrophecms/passport-bridge/index.js @@ -0,0 +1,30 @@ +export default { + options: { + // optional + create: { + role: 'guest' + }, + strategies: [ + { + // You must npm install --save this module in your project first + module: 'passport-google-oauth20', + options: { + // Options for passport-google-oauth20 + clientID: process.env.GOOGLE_CLIENT_ID, + clientSecret: process.env.GOOGLE_CLIENT_SECRET + }, + // Ignore users whose email address does not match this domain + // according to the identity provider + emailDomain: 'apostrophecms.com', + // Use the user's email address as their identity + match: 'email', + // Strategy-specific options that must be passed to the authenticate middleware. + // See the documentation of the strategy module you are using + authenticate: { + // 'email' for the obvious, 'profile' for the displayName (for the create option) + scope: [ 'email', 'profile' ] + } + } + ] + } +} \ No newline at end of file diff --git a/package.json b/package.json index 53cfd904..e067ee2f 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,11 @@ "author": "Apostrophe Technologies, Inc.", "license": "MIT", "dependencies": { + "@apostrophecms/passport-bridge": "apostrophecms/passport-bridge#pro-8013", "@apostrophecms/vite": "^1.0.0", "apostrophe": "^4.9.0", - "normalize.css": "^8.0.1" + "normalize.css": "^8.0.1", + "passport-google-oauth20": "^2.0.0" }, "devDependencies": { "autoprefixer": "^10.4.20",