fix: correctly redirect to app and check for untrusted redirects

This commit is contained in:
Stavros
2025-05-14 20:56:24 +03:00
parent ada21776bc
commit 60093997dc
4 changed files with 9 additions and 6 deletions

View File

@@ -42,7 +42,7 @@ export const ContinuePage = () => {
const url = new URL(redirectURI);
if (!(url.hostname == domain) || !url.hostname.endsWith(`.${domain}`)) {
if (!(url.hostname == domain) && !url.hostname.endsWith(`.${domain}`)) {
return (
<Card className="min-w-xs sm:min-w-sm">
<CardHeader>

View File

@@ -43,7 +43,10 @@ export const LoginPage = () => {
const isMounted = useIsMounted();
const oauthMutation = useMutation({
mutationFn: (provider: string) => axios.get(`/api/oauth/url/${provider}`),
mutationFn: (provider: string) =>
axios.get(
`/api/oauth/url/${provider}?redirect_uri=${encodeURIComponent(redirectUri ?? "")}`,
),
mutationKey: ["oauth"],
onSuccess: (data) => {
toast.info(t("loginOauthSuccessTitle"), {

View File

@@ -16,7 +16,7 @@ import { Navigate } from "react-router";
import { toast } from "sonner";
export const LogoutPage = () => {
const { provider, username, isLoggedIn } = useUserContext();
const { provider, username, isLoggedIn, email } = useUserContext();
const { genericName } = useAppContext();
const { t } = useTranslation();
@@ -56,7 +56,7 @@ export const LogoutPage = () => {
code: <code />,
}}
values={{
username: username,
username: email,
provider:
provider === "generic" ? genericName : capitalize(provider),
}}

View File

@@ -3,8 +3,8 @@ import { z } from "zod";
export const userContextSchema = z.object({
isLoggedIn: z.boolean(),
username: z.string(),
// name: z.string(), not yet implemented
// email: z.string(),
name: z.string(),
email: z.string(),
provider: z.string(),
oauth: z.boolean(),
totpPending: z.boolean(),