From 9ef9cca9482bfb9512e423b370c207004f9e1645 Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Sat, 22 Aug 2020 00:08:46 -0400 Subject: [PATCH 1/5] add samesite config setting to auth --- demo/collections/Admin.js | 1 + demo/payload.config.js | 8 ++++---- src/auth/operations/login.js | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/demo/collections/Admin.js b/demo/collections/Admin.js index 5c6faf3fa5..691b2d241d 100644 --- a/demo/collections/Admin.js +++ b/demo/collections/Admin.js @@ -23,6 +23,7 @@ module.exports = { tokenExpiration: 7200, useAPIKey: true, secureCookie: process.env.NODE_ENV === 'production', + sameSite: false, // 'strict', 'lax', 'none', true (strict) }, fields: [ { diff --git a/demo/payload.config.js b/demo/payload.config.js index c369e85223..8b7b4df8cd 100644 --- a/demo/payload.config.js +++ b/demo/payload.config.js @@ -40,10 +40,6 @@ module.exports = { }, }, }, - csrf: [ - 'http://localhost:3000', - 'https://other-app-here.com', - ], collections: [ Admin, AllFields, @@ -75,6 +71,10 @@ module.exports = { cookiePrefix: 'payload', serverURL: 'http://localhost:3000', cors: ['http://localhost', 'http://localhost:3000', 'http://localhost:8080', 'http://localhost:8081'], + csrf: [ + 'http://localhost:3000', + 'https://other-app-here.com', + ], routes: { api: '/api', admin: '/admin', diff --git a/src/auth/operations/login.js b/src/auth/operations/login.js index 5a0da4c224..90ef276db9 100644 --- a/src/auth/operations/login.js +++ b/src/auth/operations/login.js @@ -96,6 +96,10 @@ async function login(args) { cookieOptions.secure = true; } + if (collectionConfig.auth.sameSite) { + cookieOptions.sameSite = collectionConfig.auth.sameSite; + } + if (args.req.headers && args.req.headers.origin && args.req.headers.origin.indexOf('localhost') === -1) { let domain = args.req.headers.origin.replace('https://', ''); domain = domain.replace('http://', ''); From 5777868ebac7eaec8d1d2d4f986035c85e4d444e Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Fri, 21 Aug 2020 22:43:55 -0400 Subject: [PATCH 2/5] Implement page titles based upon active view --- demo/payload.config.js | 2 +- package.json | 1 + .../components/templates/Default/index.js | 6 ++ src/client/components/utilities/Meta/index.js | 74 +++++++++++++++++++ .../components/views/Account/Default.js | 6 ++ .../components/views/CreateFirstUser/index.js | 6 ++ .../components/views/ForgotPassword/index.js | 7 ++ src/client/components/views/Global/Default.js | 6 ++ src/client/components/views/Login/index.js | 11 +++ src/client/components/views/Logout/index.js | 6 ++ src/client/components/views/NotFound/index.js | 6 ++ .../components/views/ResetPassword/index.js | 7 ++ .../components/views/Unauthorized/index.js | 34 +++++---- .../views/collections/Edit/Default.js | 6 ++ .../views/collections/List/Default.js | 4 + 15 files changed, 165 insertions(+), 17 deletions(-) create mode 100644 src/client/components/utilities/Meta/index.js diff --git a/demo/payload.config.js b/demo/payload.config.js index 8b7b4df8cd..a12bcec762 100644 --- a/demo/payload.config.js +++ b/demo/payload.config.js @@ -29,7 +29,7 @@ module.exports = { admin: { user: 'admins', meta: { - titleSuffix: '- Payload', + titleSuffix: '- Payload Demo', ogImage: '/static/find-image-here.jpg', favicon: '/img/whatever.png', }, diff --git a/package.json b/package.json index 4e0c1f171d..5a44744a2a 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "react-datepicker": "^2.13.0", "react-document-meta": "^3.0.0-beta.2", "react-dom": "^16.13.1", + "react-helmet": "^6.1.0", "react-hook-form": "^5.7.2", "react-router-dom": "^5.1.2", "react-router-navigation-prompt": "^1.8.11", diff --git a/src/client/components/templates/Default/index.js b/src/client/components/templates/Default/index.js index 7c5ebfb3ad..d2df2164f7 100644 --- a/src/client/components/templates/Default/index.js +++ b/src/client/components/templates/Default/index.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import DefaultNav from '../../elements/Nav'; import { StepNavProvider } from '../../elements/StepNav'; import customComponents from '../../customComponents'; +import Meta from '../../utilities/Meta'; import './index.scss'; @@ -19,6 +20,11 @@ const Default = ({ children, className }) => { return (
+