Skip to content

Commit

Permalink
Merge branch 'main' into add_license
Browse files Browse the repository at this point in the history
  • Loading branch information
gpelouze authored Nov 29, 2024
2 parents 4fdef83 + e742c99 commit 43ef30e
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 112 deletions.
2 changes: 1 addition & 1 deletion tilt/vre-panel/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine3.16
FROM node:22-alpine
ARG NODE_ENV=test
ENV NODE_ENV $NODE_ENV

Expand Down
2 changes: 1 addition & 1 deletion tilt/vreapis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12.2-slim
FROM python:3.12.5-slim

WORKDIR /app

Expand Down
6 changes: 3 additions & 3 deletions vre-panel/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install dependencies only when needed
FROM node:21-alpine AS deps
FROM node:22-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
Expand All @@ -12,7 +12,7 @@ RUN npm install
RUN npm ci

# Rebuild the source code only when needed
FROM node:21-alpine AS builder
FROM node:22-alpine AS builder
ARG NODE_ENV
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
Expand All @@ -29,7 +29,7 @@ COPY . .
RUN npm run build

# Production image, copy all the files and run next
FROM node:21-alpine AS runner
FROM node:22-alpine AS runner
WORKDIR /app

ENV NODE_ENV production
Expand Down
2 changes: 1 addition & 1 deletion vre-panel/components/NewVREDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const NewVREDialog = ({ isOpen, setIsOpen }: { isOpen: boolean, setIsOpen: Funct
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Dialog.Overlay className="fixed inset-0 bg-black opacity-50" />
<div className="fixed inset-0 bg-black opacity-50" />
</Transition.Child>

{/* This element is to trick the browser into centering the modal contents. */}
Expand Down
2 changes: 1 addition & 1 deletion vre-panel/components/VLabInstances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const VLabInstances: React.FC<Props> = ({vlab, slug}) => {
return
}

const username = session.data.user.name
const username = session.data.user?.name

const requestOptions: RequestInit = {
method: "POST",
Expand Down
1 change: 1 addition & 0 deletions vre-panel/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- AUTH0_ID=
- AUTH0_ISSUER=
- SECRET=secret
- HOSTNAME=localhost
ports:
- '127.0.0.1:3000:3000'
healthcheck:
Expand Down
78 changes: 5 additions & 73 deletions vre-panel/next-auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,18 @@ declare module 'next-auth' {
* Returned by `useSession`, `getSession` and received as a prop on the `Provider` React Context
*/
interface Session {
user: {
sub: string;
email_verified: boolean;
name: string;
preferred_username: string;
given_name: string;
family_name: string;
email: string;
id: string;
org_name?: string;
telephone?: string;
};
accessToken?: string;
accessTokenExpiry?: number;
error: string;
accessTokenExpiry: number;
}
/**
* The shape of the user object returned in the OAuth providers' `profile` callback,
* or the second parameter of the `session` callback, when using a database.
*/
interface User {
sub: string;
email_verified: boolean;
name: string;
telephone: string;
preferred_username: string;
org_name: string;
given_name: string;
family_name: string;
email: string;
id: string;
}
/**
* Usually contains information about the provider being used
* and also extends `TokenSet`, which is different tokens returned by OAuth Providers.
*/
interface Account {
provider: string;
type: string;
id: string;
accessToken: string;
accessTokenExpires?: any;
refreshToken: string;
idToken: string;
access_token: string;
expires_at: number;
refresh_expires_in: number;
refresh_token: string;
token_type: string;
id_token: string;
'not-before-policy': number;
session_state: string;
scope: string;
}
/** The OAuth profile returned from your provider */
interface Profile {
sub: string;
email_verified: boolean;
name: string;
telephone: string;
preferred_username: string;
org_name: string;
given_name: string;
family_name: string;
email: string;
}
}

declare module 'next-auth/jwt' {
/** Returned by the `jwt` callback and `getToken`, when using JWT sessions */
interface JWT {
name: string;
email: string;
sub: string;
name: string;
email: string;
sub: string;
accessToken: string;
refreshToken: string;
accessTokenExpiry: number;
user: User;
accessToken?: string;
refreshToken?: string;
accessTokenExpiry?: number;
error: string;
}
}
4 changes: 1 addition & 3 deletions vre-panel/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ console.log(process.env.NODE_ENV);

module.exports = {
reactStrictMode: true,
experimental: {
outputStandalone: true
},
output: "standalone",
basePath: process.env.FRONTEND_BASE_PATH,
publicRuntimeConfig: {
basePath: process.env.FRONTEND_BASE_PATH,
Expand Down
27 changes: 13 additions & 14 deletions vre-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,34 @@
"lint": "next lint"
},
"dependencies": {
"@headlessui/react": "~1.7.17",
"@headlessui/react": "~2.1.2",
"@react-keycloak/ssr": "~3.3.0",
"@tailwindcss/line-clamp": "latest",
"axios": "~1.6.0",
"axios": "~1.7.3",
"clsx": "^2.0.0",
"cookie": "~0.6.0",
"http": "~0.0.1-security",
"keycloak-js": "~23.0.3",
"next": "13.4.4",
"next-auth": "~4.5.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"keycloak-js": "~25.0.2",
"next": "14.2.5",
"next-auth": "~4.24.7",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-markdown": "^9.0.0",
"react-scripts": "5.0.1",
"tailwindcss": "~3.4.1",
"use-subscription": "~1.8.0",
"object-hash": "~3.0.0",
"react-leaflet": "~4.2.1",
"leaflet": "~1.9.0"
},
"devDependencies": {
"typescript": "^4.5",
"typescript": "^5.5",
"@tailwindcss/typography": "^0.5.10",
"@types/node": "~20.11.25",
"@types/react": "~18.2.0",
"@types/node": "~22.1.0",
"@types/react": "~18.3.3",
"autoprefixer": "~10.4.15",
"axios-mock-adapter": "~1.22.0",
"eslint": "8.57.0",
"eslint-config-next": "14.1.0",
"axios-mock-adapter": "~2.0.0",
"eslint": "^8",
"eslint-config-next": "14.2.5",
"postcss": "^8.4.27",
"@types/object-hash": "~3.0.0",
"@types/leaflet": "~1.9.1"
Expand Down
16 changes: 9 additions & 7 deletions vre-panel/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from "axios";
import NextAuth from "next-auth"
import { Session } from "next-auth";
import { JWT } from "next-auth/jwt";
import KeycloakProvider from "next-auth/providers/keycloak"
import type { NextApiRequest, NextApiResponse } from 'next'
Expand Down Expand Up @@ -64,18 +65,19 @@ export default (req : NextApiRequest, res: NextApiResponse) => {
token.accessTokenExpiry = account.expires_at;
}

const expDate = new Date(token.accessTokenExpiry * 1e3)
const nowDate = new Date()
const tokenExpired = (expDate < nowDate)

if (tokenExpired) {
token = await refreshAccessToken(token);
if (token.accessTokenExpiry) {
const expDate = new Date(token.accessTokenExpiry * 1e3)
const nowDate = new Date()
const tokenExpired = (expDate < nowDate)
if (tokenExpired) {
token = await refreshAccessToken(token);
}
}

return token;

},
async session({ session, token }) {
async session({ session, token }: { session: Session, token: JWT }) {
if (token) {
session.error = token.error;
session.accessToken = token.accessToken;
Expand Down
2 changes: 1 addition & 1 deletion vreapis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12.2-slim
FROM python:3.12.5-slim

WORKDIR /app

Expand Down
14 changes: 7 additions & 7 deletions vreapis/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
django==5.0.3
djangorestframework==3.14.0
django==5.1
djangorestframework==3.15.2
djangorestframework-gis==1.0
django-filter==24.2
whitenoise==6.6.0
django-filter==24.3
whitenoise==6.7.0
gunicorn==22.0.0
pyyaml==6.0.1
requests==2.31.0
pyyaml==6.0.2
requests==2.32.3
django-dotenv==1.4.2
django-cors-headers==4.3.1
django-cors-headers==4.4.0
django-extensions==3.2.3
psycopg2==2.9.9
django-probes==1.7.0

0 comments on commit 43ef30e

Please sign in to comment.