Skip to content

Commit

Permalink
🔧 Try fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanakanajm committed Jun 1, 2024
1 parent 3e2702b commit 1220e91
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
11 changes: 9 additions & 2 deletions frontend/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@

# This is for development only. For production you need to replace this with the actual URL.
VITE_API_URL=http://localhost:8000
VITE_OAUTH_API_URL=https://134.94.199.133:7000
VITE_OAUTH_CLIENT_ID=loki-front

# IDP Settings

# IDP URL
VITE_OAUTH_API_URL=https://lokiam.de:7000

# IDP Client ID
# Dev only, change me for staging and production
VITE_OAUTH_CLIENT_ID=loki-front-dev
12 changes: 7 additions & 5 deletions frontend/src/components/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) and CISPA Helmholtz Center for Information Security
// SPDX-License-Identifier: Apache-2.0

import React from 'react';
import {ReactNode} from 'react';
import {AuthProvider as OAuth2WithPkceProvider, TAuthConfig} from 'react-oauth2-code-pkce';
Expand All @@ -11,10 +14,9 @@ function AuthProvider({children}: AuthProviderProps) {
const realm = useAppSelector((state) => state.realm.name);

const authConfig: TAuthConfig = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
clientId: import.meta.env.VITE_OAUTH_CLIENT_ID,
authorizationEndpoint: `${import.meta.env.VITE_OAUTH_API_URL}/realms/${realm}/protocol/openid-connect/auth`,
tokenEndpoint: `${import.meta.env.VITE_OAUTH_API_URL}/realms/${realm}/protocol/openid-connect/token`,
clientId: `${import.meta.env.VITE_OAUTH_CLIENT_ID || ''}`,
authorizationEndpoint: `${import.meta.env.VITE_OAUTH_API_URL || ''}/realms/${realm}/protocol/openid-connect/auth`,
tokenEndpoint: `${import.meta.env.VITE_OAUTH_API_URL || ''}/realms/${realm}/protocol/openid-connect/token`,
redirectUri: window.location.origin, // always redirect to root
scope: 'openid profile email', // default scope without audience
autoLogin: false,
Expand All @@ -23,4 +25,4 @@ function AuthProvider({children}: AuthProviderProps) {
return <OAuth2WithPkceProvider authConfig={authConfig}>{children}</OAuth2WithPkceProvider>;
}

export default AuthProvider;
export default AuthProvider;
15 changes: 11 additions & 4 deletions frontend/src/components/TopBar/RealmSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) and CISPA Helmholtz Center for Information Security
// SPDX-License-Identifier: Apache-2.0

import React from 'react';
import {FormControl, InputLabel, Select, OutlinedInput, MenuItem} from '@mui/material';
import {useAppDispatch, useAppSelector} from 'store/hooks';
Expand All @@ -8,8 +11,12 @@ function RealmSelect() {
const dispatch = useAppDispatch();

// realms are hardcoded for now
// should be fetched from keycloak
const realms = ['lha-a', 'lha-b', 'lha-c'];
// TODO: should be fetched from keycloak
const realms = [
{id: 'lha-a', name: 'LHA A', disabled: false},
{id: 'lha-b', name: 'LHA B', disabled: true},
{id: 'lha-c', name: 'LHA C', disabled: true},
];

return (
<FormControl sx={{m: 2, minWidth: 120}} size='small'>
Expand All @@ -22,8 +29,8 @@ function RealmSelect() {
input={<OutlinedInput label='Realm' />}
>
{realms.map((realm) => (
<MenuItem key={realm} value={realm}>
{realm}
<MenuItem key={realm.id} value={realm.id} disabled={realm.disabled}>
{realm.name}
</MenuItem>
))}
</Select>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/store/RealmSlice.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) and CISPA Helmholtz Center for Information Security
// SPDX-License-Identifier: Apache-2.0

import {createSlice, PayloadAction} from '@reduxjs/toolkit';

export interface Realm {
Expand Down

0 comments on commit 1220e91

Please sign in to comment.