mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-11-03 07:35:44 +00:00
fix: correctly redirect to app and check for untrusted redirects
This commit is contained in:
@@ -42,7 +42,7 @@ export const ContinuePage = () => {
|
|||||||
|
|
||||||
const url = new URL(redirectURI);
|
const url = new URL(redirectURI);
|
||||||
|
|
||||||
if (!(url.hostname == domain) || !url.hostname.endsWith(`.${domain}`)) {
|
if (!(url.hostname == domain) && !url.hostname.endsWith(`.${domain}`)) {
|
||||||
return (
|
return (
|
||||||
<Card className="min-w-xs sm:min-w-sm">
|
<Card className="min-w-xs sm:min-w-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ export const LoginPage = () => {
|
|||||||
const isMounted = useIsMounted();
|
const isMounted = useIsMounted();
|
||||||
|
|
||||||
const oauthMutation = useMutation({
|
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"],
|
mutationKey: ["oauth"],
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
toast.info(t("loginOauthSuccessTitle"), {
|
toast.info(t("loginOauthSuccessTitle"), {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { Navigate } from "react-router";
|
|||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
export const LogoutPage = () => {
|
export const LogoutPage = () => {
|
||||||
const { provider, username, isLoggedIn } = useUserContext();
|
const { provider, username, isLoggedIn, email } = useUserContext();
|
||||||
const { genericName } = useAppContext();
|
const { genericName } = useAppContext();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ export const LogoutPage = () => {
|
|||||||
code: <code />,
|
code: <code />,
|
||||||
}}
|
}}
|
||||||
values={{
|
values={{
|
||||||
username: username,
|
username: email,
|
||||||
provider:
|
provider:
|
||||||
provider === "generic" ? genericName : capitalize(provider),
|
provider === "generic" ? genericName : capitalize(provider),
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { z } from "zod";
|
|||||||
export const userContextSchema = z.object({
|
export const userContextSchema = z.object({
|
||||||
isLoggedIn: z.boolean(),
|
isLoggedIn: z.boolean(),
|
||||||
username: z.string(),
|
username: z.string(),
|
||||||
// name: z.string(), not yet implemented
|
name: z.string(),
|
||||||
// email: z.string(),
|
email: z.string(),
|
||||||
provider: z.string(),
|
provider: z.string(),
|
||||||
oauth: z.boolean(),
|
oauth: z.boolean(),
|
||||||
totpPending: z.boolean(),
|
totpPending: z.boolean(),
|
||||||
|
|||||||
Reference in New Issue
Block a user