From 45448b88341b4a45dc49d2c9a8740f6b0bc4fad0 Mon Sep 17 00:00:00 2001 From: Maria Adriana <97130795+mariadriana-deemaze@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:02:24 +0000 Subject: [PATCH] [SOA-39] Enable CSRF (#40) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor ✨ : enabled CSRF * fix ✅ (fe): hide feed actions if no authed user in context --- config/shield.ts | 4 ++-- inertia/components/posts/feed_list.tsx | 2 +- inertia/pages/feed.tsx | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config/shield.ts b/config/shield.ts index a7b794c..d3aa290 100644 --- a/config/shield.ts +++ b/config/shield.ts @@ -16,9 +16,9 @@ const shieldConfig = defineConfig({ * to learn more */ csrf: { - enabled: false, + enabled: true, exceptRoutes: [], - enableXsrfCookie: false, + enableXsrfCookie: true, methods: ['POST', 'PUT', 'PATCH', 'DELETE'], }, diff --git a/inertia/components/posts/feed_list.tsx b/inertia/components/posts/feed_list.tsx index 9ef3b12..ccc6006 100644 --- a/inertia/components/posts/feed_list.tsx +++ b/inertia/components/posts/feed_list.tsx @@ -59,7 +59,7 @@ export default function FeedList({ ) : ( allPosts?.map((post, index) => ( - + )) )}
diff --git a/inertia/pages/feed.tsx b/inertia/pages/feed.tsx index 04f797d..775828e 100644 --- a/inertia/pages/feed.tsx +++ b/inertia/pages/feed.tsx @@ -10,9 +10,11 @@ export default function Feed({ posts, user }: InferPageProps -
- -
+ {user && ( +
+ +
+ )} ) }