Skip to content

Commit

Permalink
Merge pull request #262 from QCDIS/dependabot/npm_and_yarn/vre-panel/…
Browse files Browse the repository at this point in the history
…vre-panel-npm-0bebc4a518

[npm] Bump the vre-panel-npm group in /vre-panel with 13 updates
  • Loading branch information
gpelouze authored Aug 9, 2024
2 parents a9ede32 + cdf09a8 commit e742c99
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 99 deletions.
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

0 comments on commit e742c99

Please sign in to comment.