Skip to content

Commit

Permalink
fix: add SessionAuth wrapper for protected routes (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
samjcombs authored Dec 6, 2024
1 parent 42ff1d5 commit 9a21587
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.4.1",
"main": "dist/server.js",
"scripts": {
"build": "rm -rf dist/ && npx tsc && npm run copy-graphql",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
REACT_APP_FRONTEND_REQUIRE_AUTH: true
container_name: instant-mock
environment:
REQUIRE_AUTH: true
BACKEND_REQUIRE_AUTH: true
PORT: "${BACKEND_PORT:-3033}"
NODE_ENV: "production"
HOST: "0.0.0.0"
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.4.1",
"private": true,
"dependencies": {
"@apollo/explorer": "^3.7.0",
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
import SuperTokens, {SuperTokensWrapper} from 'supertokens-auth-react';
import {SessionAuth} from 'supertokens-auth-react/recipe/session';
import CallbackHandler from './CallbackHandler';
import Home from './components/ui/home';
import Login from './components/ui/login';
Expand All @@ -13,16 +14,19 @@ if (config.requireAuth) {
}

function AppRoutes() {
const protectedElement = (element: JSX.Element) =>
config.requireAuth ? <SessionAuth>{element}</SessionAuth> : element;

return (
<Router>
<Routes>
<Route
path={'/auth/callback/:providerId'}
path="/auth/callback/:providerId"
element={<CallbackHandler />}
/>
<Route path={'/auth'} element={<Login />} />
<Route path="/" element={<Home />} />
<Route path="/settings" element={<SettingsPage />} />
<Route path="/auth" element={<Login />} />
<Route path="/" element={protectedElement(<Home />)} />
<Route path="/settings" element={protectedElement(<SettingsPage />)} />
<Route path="*" element={<NotFound />} />
</Routes>
</Router>
Expand Down
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
name: instantmock
description: A Helm chart for deploying InstantMock
version: 0.2.0
appVersion: "1.0.0-beta.4"
appVersion: "1.0.0-beta.4.1"
2 changes: 1 addition & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 1
image:
repository: xolvio/instant-mock
tag: 1.0.0-beta.4
tag: 1.0.0-beta.4.1
pullPolicy: Always
service:
type: ClusterIP
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instant-mock",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.4.1",
"description": "![instant-mock-screen-cap-final](https://github.com/user-attachments/assets/de0f50d4-5a71-4e5a-b479-37c6cfa0481d)",
"main": "index.js",
"module": "true",
Expand Down

0 comments on commit 9a21587

Please sign in to comment.