Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2/backend/rbac -> v2/staging #548

Open
wants to merge 93 commits into
base: v2/staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
f2887c8
rename web, update schema, add logto
finnc0 Dec 24, 2023
951ac64
add logto api routes and callbacks
finnc0 Dec 24, 2023
b61d6aa
fix env vars, update some other things
finnc0 Dec 24, 2023
ea9ed33
fix user data util functions
finnc0 Dec 24, 2023
373b5b8
v1->v2 migration logic done
finnc0 Dec 24, 2023
0cd8c93
add infractions model & update migration endpoint
finnc0 Dec 24, 2023
eff5ec0
update migrations
finnc0 Dec 25, 2023
cb38a32
fix some possible future issues + session method
finnc0 Dec 25, 2023
1ad7c9b
auth done + site context updated
finnc0 Dec 25, 2023
873bd31
add ui package and setup tw
finnc0 Dec 26, 2023
deab060
add waldo button comp
finnc0 Dec 26, 2023
66b7056
fix mobile viewport bug
finnc0 Jan 1, 2024
7ac7432
refactor: tailwind config centralized
finnc0 Jan 3, 2024
f79ec97
refactor: categorize ui comps
finnc0 Jan 3, 2024
410d20e
chore: setup landing app
finnc0 Jan 3, 2024
3a25f43
refactor: landing & app & updated globals.css
finnc0 Jan 3, 2024
033e625
feat: landing page section 1 done
finnc0 Jan 3, 2024
4fab4ad
fix(color): landing social items
finnc0 Jan 3, 2024
7633f16
fix: hot reloading bug due to bad layout
finnc0 Jan 3, 2024
0a02271
refactor: remove create account btn
finnc0 Jan 3, 2024
c492d3f
update: landing app metadata
finnc0 Jan 3, 2024
aea8867
chore: prep web app for recode
finnc0 Jan 5, 2024
fbdde64
chore: update depends in landing & app
finnc0 Jan 5, 2024
7bebc39
refactor: remove old next auth util
finnc0 Jan 5, 2024
c6194f6
add: v2 app file structure (app router)
finnc0 Jan 5, 2024
6cb2cff
refactor: shrink next-auth down to bare min for migration testing
finnc0 Jan 5, 2024
afaebaf
refactor: update tsconfig @ paths
finnc0 Jan 5, 2024
cd2acfb
feat: move logto over to app router
finnc0 Jan 5, 2024
8aae1e9
feat: add migration route to app router
finnc0 Jan 5, 2024
3f7693e
refactor: centralize v2session type
finnc0 Jan 5, 2024
7d50550
refactor: bump prisma client ver
finnc0 Jan 5, 2024
aa4b008
feat(ui): added waldo input comp
finnc0 Jan 8, 2024
1e24976
feat(API): add authorization prot & start rbac
finnc0 Jan 9, 2024
66f0722
chore(API): remove all hardcoded uris for env vars
finnc0 Jan 9, 2024
25700f0
fix(API): added next_public to some env vars
finnc0 Jan 9, 2024
489e300
refactor(api): comment some things and fix env var
finnc0 Jan 9, 2024
b54fcad
fix(api): env var mis-match
finnc0 Jan 9, 2024
d5f0812
feat(api): finish authorization resource & centralize id
finnc0 Jan 9, 2024
d3cd315
chore(pkg:api): add .env; type .env; update app .env
finnc0 Jan 9, 2024
9df7821
refactor(pkg:id): add .env.example
finnc0 Jan 9, 2024
5dc8f32
fix(packages/identity): referencing hard coded logto api resource
web-flow Jan 9, 2024
cbf2603
feat(server/trpc): start rbac refactor
arthur-rl Jan 9, 2024
d5605c9
add(server/trpc): getSiteData to new folder structure
arthur-rl Jan 9, 2024
6a2026e
feat(server/trpc): updatePage to new rbac authentication
arthur-rl Jan 9, 2024
5a2de07
feat(server/trpc): updateSite to new rbac authentiction
arthur-rl Jan 9, 2024
89adfda
feat(trpc/context): userHasScope function
arthur-rl Jan 9, 2024
a401d98
refactor(trpc/routes): change gameplay routes over to new file struct…
arthur-rl Jan 13, 2024
fd3cd60
tweak(packages/identity): update session type and requested scope
arthur-rl Jan 13, 2024
77ea3f9
Merge branch 'v2/backend/rbac' of https://github.com/waldo-vision/wal…
arthur-rl Jan 13, 2024
b57435e
fix(env error): put env vars in turbo
finnc0 Jan 13, 2024
c642f2b
refactor(files): save files with LF format
finnc0 Jan 13, 2024
a26f29c
refactor(schema/migrations): rmvd mg dir & rmvd role field on user model
finnc0 Jan 16, 2024
dc89bd9
chore(server): fix some major sec issues & finish file structure over…
finnc0 Jan 16, 2024
3447cc6
refactor(schema): renamed a vote model and changed infrac type
finnc0 Jan 16, 2024
779ba0f
feat(scopes): manage scopes within identity pkg instead of manually w…
finnc0 Jan 16, 2024
7b8467d
fix(scopes): fixed some export issues
finnc0 Jan 16, 2024
9b7d007
fix(vars,),feat(mapi): fixed env var, started machine-to-machine api
finnc0 Jan 17, 2024
72ee3e0
feat(mapi): add logto roles to server session
finnc0 Jan 17, 2024
f10d790
fix(mapi): remove hard coded uri
finnc0 Jan 17, 2024
f47b7fb
chore(gp router): add try/catch block
finnc0 Jan 18, 2024
74a2563
chore(routers): add try/catch blocks, fix returns and some other stuff
finnc0 Jan 18, 2024
471f99b
feat(mapi/badges): start work on v2 fr's
finnc0 Jan 19, 2024
c67a1d3
fix(mapi): remove testing code from endpoint
finnc0 Jan 19, 2024
f665856
feat(next14): move trpc and everything over to next14, server comps
finnc0 Jan 21, 2024
695583b
fix(env): remove hard coded env var
finnc0 Jan 21, 2024
bfed1e3
refactor(next.config): add back prev diff
finnc0 Jan 21, 2024
e585fec
refactor: clean a few things up
finnc0 Mar 16, 2024
33f7721
refactor: move old comps into dep folder
finnc0 Mar 16, 2024
642af3e
feats(v2): add platform home page, header & sidebar
finnc0 Mar 16, 2024
e2497cb
feat(v2): add session context
finnc0 Mar 16, 2024
78022a3
feat(v2): populate dash with session data & fix session data bug
finnc0 Mar 16, 2024
92cdb2b
fix(header / page): add redirects to button hrefs
finnc0 Mar 18, 2024
86c82e1
refactor/feat(dash): add loading comp, update session init stuff
finnc0 Mar 20, 2024
22f8456
feat(session): add id field from waldo model, some other sessin stuff
finnc0 Mar 20, 2024
f81ca32
feat(auth api): prepare for novu integration, refactor & comment rout…
finnc0 Mar 20, 2024
7e8f5a5
refactor(session): add comments & refactor a few things
finnc0 Mar 20, 2024
4efb046
feat(session): add scopes field to session obj
finnc0 Mar 20, 2024
3a2e8ed
refactor(session): updating naming in createSession method
finnc0 Mar 20, 2024
a7b919c
feat(novu): novu integration done (WIP)
finnc0 Mar 21, 2024
5d8fcab
fix(novu): a bunch of bugs & errors fixed
finnc0 Mar 21, 2024
88bb20e
feat(sidebar): add collapsible menu, start on submission pages
finnc0 Mar 22, 2024
9c24871
refactor(sidebar): remove unused imports
finnc0 Mar 22, 2024
d9066dc
refactor(header): remove console.logs
finnc0 Mar 22, 2024
08f5fb8
feat(dash): start work on dash page content
finnc0 Mar 23, 2024
39c4756
feat(sidebar): update submission nav options
finnc0 Mar 23, 2024
d1c94fc
feat(sidebars, bugs): finished sidebars, worked on responsive layout
finnc0 Mar 24, 2024
a17cbe5
fix(layout): add ! to conditional
finnc0 Mar 24, 2024
d688649
fix(keys): add key prop to some elements
finnc0 Mar 24, 2024
047edaf
fix(breakpoints): fix mobile breakpoints
finnc0 Mar 24, 2024
bf14edb
fix(session reqs): fix constant api req
finnc0 Mar 24, 2024
1f461a9
fix(mobile sidebar): remove fixed height
finnc0 Mar 24, 2024
7d8641b
fix(sidebar): loading href check fixed
finnc0 Mar 24, 2024
f019fe4
feat(upload): upload page logic wip
finnc0 Mar 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"development"
],
"hints": {
"axe/forms": [
"default",
{
"label": "off"
}
]
}
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
Expand All @@ -10,6 +10,9 @@
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
},
"cSpell.words": [
"chakra",
"CIMG",
Expand Down
42 changes: 42 additions & 0 deletions apps/app/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# Google Recaptcha
RECAPTCHA_SITE_KEY=your_site_key
RECAPTCHA_SECRET_KEY=your_secret_key


# database
DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432?sslmode=disable"

# Logto

NEXT_PUBLIC_BASE_URL="" #// E.g. http://localhost:3000
COOKIESECRET='complex_password_at_least_32_characters_long'

# logto authorization / security
NEXT_PUBLIC_ID_ISSUER=""
NEXT_PUBLIC_RESOURCE_AUDIENCE="https://api.foo.bar/api"
NEXT_PUBLIC_JWKS_ENDPOINT=https://localhost:3001/oidc/jwks

# Local Dev Stuff
HTTPS_CERT_PATH=""
HTTPS_KEY_PATH=""
NODE_TLS_REJECT_UNAUTHORIZED=0

# disable authentication verification (ONLY USE FOR TESTING PURPOSES)
#DISABLE_VERIFY_AUTH=0

APP_ID=""
APP_SECRET=""
ENDPOINT=""
BASE_URL=""
COOKIE_SECRET=""

MAPI_APP_ID=""
MAPI_APP_SECRET=""
MAPI_TOKEN_ENDPOINT=""
MAPI_RESOURCE_URI="https://default.logto.app/api"

NOVU_API_KEY=""
NOVU_BACKEND_URL=""
NOVU_WS_URL=""
NEXT_PUBLIC_NOVU_APP_ID=""
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions apps/app/additional.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
declare namespace NodeJS {
interface ProcessEnv {
RECAPTCHA_SITE_KEY: string;
RECAPTCHA_SECRET_KEY: string;
DATABASE_URL: string;
APP_ID: string;
APP_SECRET: string;
ENDPOINT: string;
BASE_URL: string;
NEXT_PUBLIC_BASE_URL: string;
COOKIE_SECRET: string;
MAPI_APP_ID: string;
MAPI_APP_SECRET: string;
MAPI_TOKEN_ENDPOINT: string;
MAPI_RESOURCE_URI: string;
NODE_ENV: string;
NEXT_PUBLIC_BASE_URL: string;
NEXT_PUBLIC_JWKS_ENDPOINT: string;
NEXT_PUBLIC_RESOURCE_AUDIENCE: string;
NEXT_PUBLIC_ID_ISSUER: string;
NOVU_API_KEY: string;
NEXT_PUBLIC_NOVU_BACKEND_URL: string;
NEXT_PUBLIC_NOVU_WS_URL: string;
NEXT_PUBLIC_NOVU_APP_ID: string;
}
}
83 changes: 83 additions & 0 deletions apps/app/app/_styles/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 47.4% 11.2%;

--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;

--popover: 0 0% 100%;
--popover-foreground: 222.2 47.4% 11.2%;

--card: 0 0% 100%;
--card-foreground: 222.2 47.4% 11.2%;

--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;

--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;

--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;

--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;

--destructive: 0 100% 50%;
--destructive-foreground: 210 40% 98%;

--ring: 215 20.2% 65.1%;

--radius: 0.5rem;
}

.dark {
--background: 224 71% 4%;
--foreground: 213 31% 91%;

--muted: 223 47% 11%;
--muted-foreground: 215.4 16.3% 56.9%;

--popover: 224 71% 4%;
--popover-foreground: 215 20.2% 65.1%;

--card: 224 71% 4%;
--card-foreground: 213 31% 91%;

--border: 216 34% 17%;
--input: 216 34% 17%;

--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 1.2%;

--secondary: 222.2 47.4% 11.2%;
--secondary-foreground: 210 40% 98%;

--accent: 216 34% 17%;
--accent-foreground: 210 40% 98%;

--destructive: 0 63% 31%;
--destructive-foreground: 210 40% 98%;

--ring: 216 34% 17%;

--radius: 0.5rem;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
font-feature-settings: 'rlig' 1, 'calt' 1;
}
}
31 changes: 31 additions & 0 deletions apps/app/app/_styles/novu.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
body {
font-family: poppins;
-webkit-font-smoothing: auto;
-moz-font-smoothing: auto;
-moz-osx-font-smoothing: grayscale;
font-smoothing: auto;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: always;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
background-color: grey;
}

h1 {
font-size: 1.5rem;
font-weight: bold;
margin-bottom: 1rem;
}
h2 {
font-size: 1.2rem;
font-weight: normal;
margin-bottom: 1rem;
}
h3 {
font-size: 1rem;
font-weight: normal;
}

body {
background-color: black;
}
64 changes: 64 additions & 0 deletions apps/app/app/_trpc/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { type inferRouterInputs, type inferRouterOutputs } from '@trpc/server';
import superjson from 'superjson';
import {
experimental_createActionHook,
experimental_createTRPCNextAppDirClient,
experimental_serverActionLink,
} from '@trpc/next/app-dir/client';
import { experimental_nextHttpLink } from '@trpc/next/app-dir/links/nextHttp';
import { type AppRouter } from '@server/trpc/router/_app';
import axios from 'axios';
import { cookies } from 'next/headers';

const retrieveAccessToken = async () => {
const req = await axios.get(
process.env.NEXT_PUBLIC_BASE_URL + '/api/logto/accesstoken',
{
withCredentials: true,
headers: {
Cookie: cookies().toString(),
},
},
);
const res = await req.data;
if (!res.accessToken) return undefined;
return res.accessToken;
// gets returned and piped into TRPC headers
};

/**
* Trpc client for the frontend
*/
export const trpc = experimental_createTRPCNextAppDirClient<AppRouter>({
config() {
return {
transformer: superjson,
links: [
experimental_nextHttpLink({
batch: false,
url: `${process.env.NEXT_PUBLIC_BASE_URL}/api/trpc`,
headers: async () => {
return {
Authorization:
(await retrieveAccessToken()) == undefined
? undefined
: `Bearer ${await retrieveAccessToken()}`,
cookie: cookies().toString(),
};
},
}),
],
};
},
});

/**
* Inference helper for inputs
* @example type HelloInput = RouterInputs['example']['hello']
**/
export type RouterInputs = inferRouterInputs<AppRouter>;
/**
* Inference helper for outputs
* @example type HelloOutput = RouterOutputs['example']['hello']
**/
export type RouterOutputs = inferRouterOutputs<AppRouter>;
45 changes: 45 additions & 0 deletions apps/app/app/_trpc/serverClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { experimental_nextHttpLink } from '@trpc/next/app-dir/links/nextHttp';
import { experimental_createTRPCNextAppDirServer } from '@trpc/next/app-dir/server';
import type { AppRouter } from '@server/trpc/router/_app';
import { cookies } from 'next/headers';
import superjson from 'superjson';
import axios from 'axios';
const retrieveAccessToken = async () => {
const req = await axios.get(
process.env.NEXT_PUBLIC_BASE_URL + '/api/logto/accesstoken',
{
withCredentials: true,
headers: {
Cookie: cookies().toString(),
},
},
);
const res = await req.data;
if (!res.accessToken) return undefined;
return res.accessToken;
// gets returned and piped into TRPC headers
};

export const api = experimental_createTRPCNextAppDirServer<AppRouter>({
config() {
return {
transformer: superjson,
links: [
experimental_nextHttpLink({
revalidate: false,
batch: true,
url: `${process.env.NEXT_PUBLIC_BASE_URL}/api/trpc`,
headers: async () => {

return {
Authorization: `Bearer ${await retrieveAccessToken()}`,
cookie: cookies().toString(),
};
},
}),
],
};
},
});

// export const createAction =
Empty file added apps/app/app/account/page.tsx
Empty file.
Empty file.
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions apps/app/app/api/logto/accesstoken/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { logtoClient } from 'identity';
import { NextRequest } from 'next/server';

export async function GET(request: NextRequest) {
return logtoClient.handleUser({
fetchUserInfo: true,
getAccessToken: true,
resource: process.env.NEXT_PUBLIC_RESOURCE_AUDIENCE,
})(request);
}
Loading
Loading