Skip to content

Commit 59af70c

Browse files
committed
Remove oidc-client
1 parent ad4892f commit 59af70c

File tree

23 files changed

+134
-456
lines changed

23 files changed

+134
-456
lines changed

frontend-config.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
{
2-
"backendUrl": "http://localhost:3000",
32
"gatewayUrl": "http://localhost:3000",
43
"landscape": "LOCAL",
5-
"documentationBaseUrl": "http://localhost:3000",
6-
"oidcConfig": {
7-
"clientId": "clientId",
8-
"issuerUrl": "issuer-url",
9-
"scopes": []
10-
}
4+
"documentationBaseUrl": "http://localhost:3000"
115
}

package-lock.json

Lines changed: 14 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@
4343
"i18next": "^25.0.0",
4444
"javascript-time-ago": "^2.5.11",
4545
"js-yaml": "^4.1.0",
46-
"oidc-client-ts": "^3.1.0",
4746
"react": "19.1.0",
4847
"react-dom": "19.1.0",
4948
"react-error-boundary": "^6.0.0",
5049
"react-hook-form": "^7.54.2",
5150
"react-i18next": "^15.4.1",
52-
"react-oidc-context": "^3.2.0",
5351
"react-router-dom": "^7.2.0",
5452
"react-syntax-highlighter": "^15.6.1",
5553
"react-time-ago": "^7.3.3",

public/locales/en.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@
117117
"columnEmailHeader": "Email",
118118
"columnRoleHeader": "Role"
119119
},
120-
"SessionExpiringDialog": {
121-
"dialogHeader": "Your session is expiring soon...",
122-
"signOutButton": "Sign Out",
123-
"stayButton": "Stay Signed In",
124-
"sessionText": "Your session expires soon and you will be signed out automatically. To continue working, press 'Stay Signed in'."
125-
},
126120
"IllustratedError": {
127121
"titleText": "Something went wrong",
128122
"subtitleText": "Contact admins for help"

server/routes/auth.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,17 @@ async function authPlugin(fastify) {
5252
});
5353

5454

55-
fastify.get("/auth/status", async (req, reply) => {
56-
const isAuthenticated = Boolean(req.session.get("accessToken"));
57-
reply.send({ isAuthenticated });
58-
});
59-
55+
fastify.get("/auth/me", async (req, reply) => {
56+
const accessToken = req.session.get("accessToken");
57+
const userInfo = req.session.get("userInfo");
6058

61-
fastify.get("/auth/user", async (req, reply) => {
62-
reply.send(req.session.get("userInfo"));
59+
const isAuthenticated = Boolean(accessToken);
60+
const user = isAuthenticated ? userInfo : null;
61+
reply.send({ isAuthenticated, user });
6362
});
6463

6564

66-
fastify.get("/auth/logout", async (_req, reply) => {
65+
fastify.post("/auth/logout", async (_req, reply) => {
6766
// TODO: Idp sign out flow
6867
//_req.session.delete(); // remove payload
6968
reply.clearCookie(COOKIE_NAME_ONBOARDING, { path: "/" });

src/App.tsx

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import AppRouter from './AppRouter';
22
import { useAuth } from './spaces/onboarding/auth/AuthContext.tsx';
33
import '@ui5/webcomponents-icons/dist/AllIcons.d.ts';
4-
import { useEffect, useState } from 'react';
5-
import { SessionExpiringDialog } from './components/Dialogs/SessionExpiringDialog.tsx';
4+
import { useEffect } from 'react';
65
import { useFrontendConfig } from './context/FrontendConfigContext.tsx';
76
import { useTranslation } from 'react-i18next';
7+
import LoginView from './views/Login.tsx';
88

99
function App() {
1010
const auth = useAuth();
11-
const [dialogSessionExpiringIsOpen, setDialogSessionExpiringIsOpen] =
12-
useState(false);
1311
const { t } = useTranslation();
14-
1512
const frontendConfig = useFrontendConfig();
1613

1714
useEffect(() => {
@@ -25,27 +22,10 @@ function App() {
2522
}
2623

2724
if (!auth.isAuthenticated) {
28-
return (
29-
<>
30-
{/**<LoginView />**/}
31-
<button onClick={() => auth.login()}>Sign In</button>
32-
</>
33-
);
25+
return <LoginView />;
3426
}
3527

36-
return (
37-
<>
38-
<SessionExpiringDialog
39-
isOpen={dialogSessionExpiringIsOpen}
40-
setIsOpen={setDialogSessionExpiringIsOpen}
41-
/>
42-
<div>
43-
{auth.isAuthenticated ? 'AUTHED' : 'NOT AUTHED'}
44-
<button onClick={() => auth.logout()}>Sign Out</button>
45-
</div>
46-
<AppRouter />
47-
</>
48-
);
28+
return <AppRouter />;
4929
}
5030

5131
export default App;

src/components/Core/ApiConfigWrapper.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
import { ApiConfigProvider } from '../Shared/k8s/index.ts';
22
import { Outlet } from 'react-router-dom';
3-
import { useAuth } from 'react-oidc-context';
43
import { generateCrateAPIConfig } from '../../lib/api/types/apiConfig.ts';
5-
import { useFrontendConfig } from '../../context/FrontendConfigContext.tsx';
64

75
// ApiConfigWrapper is a component that provides the ApiConfigProvider with the oidc access token from the oidc context.
86
export default function ApiConfigWrapper() {
9-
const auth = useAuth();
10-
const token = !auth.isAuthenticated ? '' : auth.user?.access_token;
11-
const { backendUrl } = useFrontendConfig();
12-
137
return (
148
<>
15-
<ApiConfigProvider
16-
apiConfig={generateCrateAPIConfig(backendUrl, token ?? '')}
17-
>
9+
<ApiConfigProvider apiConfig={generateCrateAPIConfig()}>
1810
<Outlet />
1911
</ApiConfigProvider>
2012
</>

src/components/Core/ShellBar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ShellBarDomRef,
1212
Ui5CustomEvent,
1313
} from '@ui5/webcomponents-react';
14-
import { useAuth } from 'react-oidc-context';
14+
import { useAuth } from '../../spaces/onboarding/auth/AuthContext.tsx';
1515
import { RefObject, useEffect, useRef, useState } from 'react';
1616
import { ShellBarProfileClickEventDetail } from '@ui5/webcomponents-fiori/dist/ShellBar.js';
1717
import PopoverPlacement from '@ui5/webcomponents/dist/types/PopoverPlacement.js';
@@ -59,7 +59,7 @@ export function ShellBarComponent() {
5959
className={styles.TestShellbar}
6060
profile={
6161
<Avatar
62-
initials={generateInitialsForEmail(auth.user?.profile.email)}
62+
initials={generateInitialsForEmail(auth.user?.email)}
6363
size="XS"
6464
/>
6565
}
@@ -123,7 +123,7 @@ const ProfilePopover = ({
123123
icon="log"
124124
onClick={() => {
125125
setOpen(false);
126-
auth.removeUser();
126+
void auth.logout();
127127
}}
128128
>
129129
{t('ShellBar.signOutButton')}

src/components/Dialogs/CreateProjectDialogContainer.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import {
88
} from './CreateProjectWorkspaceDialog.tsx';
99

1010
import { useToast } from '../../context/ToastContext.tsx';
11-
import { useAuthSubject } from '../../lib/oidc/useUsername.ts';
11+
import { useAuth } from '../../spaces/onboarding/auth/AuthContext.tsx';
1212
import { MemberRoles } from '../../lib/api/types/shared/members.ts';
1313

1414
import { useTranslation } from 'react-i18next';
15-
1615
import { zodResolver } from '@hookform/resolvers/zod';
1716
import { useForm } from 'react-hook-form';
1817
import {
@@ -46,10 +45,10 @@ export function CreateProjectDialogContainer({
4645
members: [],
4746
},
4847
});
49-
50-
const username = useAuthSubject();
51-
5248
const { t } = useTranslation();
49+
const { user } = useAuth();
50+
51+
const username = user?.email;
5352

5453
const clearForm = useCallback(() => {
5554
resetField('name');

src/components/Dialogs/CreateWorkspaceDialogContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { projectnameToNamespace } from '../../utils';
1818
import { ListWorkspaces } from '../../lib/api/types/crate/listWorkspaces';
1919
import { useToast } from '../../context/ToastContext.tsx';
20-
import { useAuthSubject } from '../../lib/oidc/useUsername.ts';
20+
import { useAuth } from '../../spaces/onboarding/auth/AuthContext.tsx';
2121
import { Member, MemberRoles } from '../../lib/api/types/shared/members.ts';
2222
import { useTranslation } from 'react-i18next';
2323
import { zodResolver } from '@hookform/resolvers/zod';
@@ -56,10 +56,10 @@ export function CreateWorkspaceDialogContainer({
5656
members: [],
5757
},
5858
});
59-
60-
const username = useAuthSubject();
61-
6259
const { t } = useTranslation();
60+
const { user } = useAuth();
61+
62+
const username = user?.email;
6363

6464
const clearForm = useCallback(() => {
6565
resetField('name');

0 commit comments

Comments
 (0)