From fe391fc5714d24f753b0940880788159200a799c Mon Sep 17 00:00:00 2001 From: Stavros Date: Mon, 26 Jan 2026 16:20:49 +0200 Subject: [PATCH] fix: more review comments --- frontend/src/lib/i18n/locales/en-US.json | 13 ++- frontend/src/lib/i18n/locales/en.json | 13 ++- frontend/src/pages/authorize-page.tsx | 74 +++++++++++- .../controller/context_controller_test.go | 40 +++---- internal/controller/oidc_controller.go | 16 +-- internal/controller/oidc_controller_test.go | 108 ++++++++++++++++-- internal/repository/oidc_queries.sql.go | 44 ++++++- internal/service/oidc_service.go | 5 +- sql/oidc_queries.sql | 14 ++- 9 files changed, 270 insertions(+), 57 deletions(-) diff --git a/frontend/src/lib/i18n/locales/en-US.json b/frontend/src/lib/i18n/locales/en-US.json index 9bc7e7e..a1f2768 100644 --- a/frontend/src/lib/i18n/locales/en-US.json +++ b/frontend/src/lib/i18n/locales/en-US.json @@ -62,9 +62,18 @@ "goToCorrectDomainTitle": "Go to correct domain", "authorizeTitle": "Authorize", "authorizeCardTitle": "Continue to {{app}}?", - "authorizeSubtitle": "Would you like to continue to this app? Please keep in mind that this app will have access to your email and other information.", + "authorizeSubtitle": "Would you like to continue to this app? Please carefully review the permissions requested by the app.", + "authorizeSubtitleOAuth": "Would you like to continue to this app?", "authorizeLoadingTitle": "Loading...", "authorizeLoadingSubtitle": "Please wait while we load the client information.", "authorizeSuccessTitle": "Authorized", - "authorizeSuccessSubtitle": "You will be redirected to the app in a few seconds." + "authorizeSuccessSubtitle": "You will be redirected to the app in a few seconds.", + "openidScopeName": "OpenID Connect", + "openidScopeDescription": "Allows the app to access your OpenID Connect information.", + "emailScopeName": "Email", + "emailScopeDescription": "Allows the app to access your email address.", + "profileScopeName": "Profile", + "profileScopeDescription": "Allows the app to access your profile information.", + "groupsScopeName": "Groups", + "groupsScopeDescription": "Allows the app to access the groups in which you are a member." } diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index 9bc7e7e..a1f2768 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -62,9 +62,18 @@ "goToCorrectDomainTitle": "Go to correct domain", "authorizeTitle": "Authorize", "authorizeCardTitle": "Continue to {{app}}?", - "authorizeSubtitle": "Would you like to continue to this app? Please keep in mind that this app will have access to your email and other information.", + "authorizeSubtitle": "Would you like to continue to this app? Please carefully review the permissions requested by the app.", + "authorizeSubtitleOAuth": "Would you like to continue to this app?", "authorizeLoadingTitle": "Loading...", "authorizeLoadingSubtitle": "Please wait while we load the client information.", "authorizeSuccessTitle": "Authorized", - "authorizeSuccessSubtitle": "You will be redirected to the app in a few seconds." + "authorizeSuccessSubtitle": "You will be redirected to the app in a few seconds.", + "openidScopeName": "OpenID Connect", + "openidScopeDescription": "Allows the app to access your OpenID Connect information.", + "emailScopeName": "Email", + "emailScopeDescription": "Allows the app to access your email address.", + "profileScopeName": "Profile", + "profileScopeDescription": "Allows the app to access your profile information.", + "groupsScopeName": "Groups", + "groupsScopeDescription": "Allows the app to access the groups in which you are a member." } diff --git a/frontend/src/pages/authorize-page.tsx b/frontend/src/pages/authorize-page.tsx index ecbd832..ede9a24 100644 --- a/frontend/src/pages/authorize-page.tsx +++ b/frontend/src/pages/authorize-page.tsx @@ -8,6 +8,7 @@ import { CardTitle, CardDescription, CardFooter, + CardContent, } from "@/components/ui/card"; import { getOidcClientInfoScehma } from "@/schemas/oidc-schemas"; import { Button } from "@/components/ui/button"; @@ -15,12 +16,55 @@ import axios from "axios"; import { toast } from "sonner"; import { useOIDCParams } from "@/lib/hooks/oidc"; import { useTranslation } from "react-i18next"; +import { TFunction } from "i18next"; +import { Mail, Shield, User, Users } from "lucide-react"; + +type Scope = { + id: string; + name: string; + description: string; + icon: React.ReactNode; +}; + +const scopeMapIconProps = { + className: "stroke-card stroke-2.5", +}; + +const createScopeMap = (t: TFunction<"translation", undefined>): Scope[] => { + return [ + { + id: "openid", + name: t("openidScopeName"), + description: t("openidScopeDescription"), + icon: , + }, + { + id: "email", + name: t("emailScopeName"), + description: t("emailScopeDescription"), + icon: , + }, + { + id: "profile", + name: t("profileScopeName"), + description: t("profileScopeDescription"), + icon: , + }, + { + id: "groups", + name: t("groupsScopeName"), + description: t("groupsScopeDescription"), + icon: , + }, + ]; +}; export const AuthorizePage = () => { const { isLoggedIn } = useUserContext(); const { search } = useLocation(); const { t } = useTranslation(); const navigate = useNavigate(); + const scopeMap = createScopeMap(t); const searchParams = new URLSearchParams(search); const { @@ -29,6 +73,7 @@ export const AuthorizePage = () => { isOidc, compiled: compiledOIDCParams, } = useOIDCParams(searchParams); + const scopes = props.scope.split(" "); const getClientInfo = useQuery({ queryKey: ["client", props.client_id], @@ -100,15 +145,40 @@ export const AuthorizePage = () => { } return ( - + {t("authorizeCardTitle", { app: getClientInfo.data?.name || "Unknown", })} - {t("authorizeSubtitle")} + + {scopes.includes("openid") + ? t("authorizeSubtitle") + : t("authorizeSubtitleOAuth")} + + {scopes.includes("openid") && ( + + {scopes.map((id) => { + const scope = scopeMap.find((s) => s.id === id); + if (!scope) return null; + return ( +
+
+ {scope.icon} +
+
+
{scope.name}
+
+ {scope.description} +
+
+
+ ); + })} +
+ )}