Compare commits

..

3 Commits

Author SHA1 Message Date
Stavros
ce8493239e fix: don't escape backend values in the frontend (translations) 2026-02-11 19:25:33 +02:00
Stavros
71fe73cca0 chore: fix typo in makefile develop recipe 2026-02-11 19:13:09 +02:00
Stavros
0fe89ae4e4 chore: use sslip in development compose 2026-02-11 19:08:43 +02:00
6 changed files with 41 additions and 38 deletions

3
.gitignore vendored
View File

@@ -39,6 +39,3 @@ __debug_*
# infisical # infisical
/.infisical.json /.infisical.json
# traefik data
/traefik

View File

@@ -10,7 +10,7 @@ BUILD_TIMESTAMP := $(shell date '+%Y-%m-%dT%H:%M:%S')
BIN_NAME := tinyauth-$(GOARCH) BIN_NAME := tinyauth-$(GOARCH)
# Development vars # Development vars
DEV_COMPOSE := $(shell test -f "docker-compose.test.yml" && echo "docker-compose.test.yml" || echo "docker-compose.yml" ) DEV_COMPOSE := $(shell test -f "docker-compose.test.yml" && echo "docker-compose.test.yml" || echo "docker-compose.dev.yml" )
PROD_COMPOSE := $(shell test -f "docker-compose.test.prod.yml" && echo "docker-compose.test.prod.yml" || echo "docker-compose.example.yml" ) PROD_COMPOSE := $(shell test -f "docker-compose.test.prod.yml" && echo "docker-compose.test.prod.yml" || echo "docker-compose.example.yml" )
# Deps # Deps

View File

@@ -13,7 +13,7 @@ services:
image: traefik/whoami:latest image: traefik/whoami:latest
labels: labels:
traefik.enable: true traefik.enable: true
traefik.http.routers.whoami.rule: Host(`whoami.example.com`) traefik.http.routers.whoami.rule: Host(`whoami.127.0.0.1.sslip.io`)
traefik.http.routers.whoami.middlewares: tinyauth traefik.http.routers.whoami.middlewares: tinyauth
tinyauth-frontend: tinyauth-frontend:
@@ -27,7 +27,7 @@ services:
- 5173:5173 - 5173:5173
labels: labels:
traefik.enable: true traefik.enable: true
traefik.http.routers.tinyauth.rule: Host(`tinyauth.example.com`) traefik.http.routers.tinyauth.rule: Host(`tinyauth.127.0.0.1.sslip.io`)
tinyauth-backend: tinyauth-backend:
container_name: tinyauth-backend container_name: tinyauth-backend

View File

@@ -33,6 +33,7 @@ export const DomainWarning = (props: Props) => {
i18nKey="domainWarningSubtitle" i18nKey="domainWarningSubtitle"
values={{ appUrl, currentUrl }} values={{ appUrl, currentUrl }}
components={{ code: <code /> }} components={{ code: <code /> }}
shouldUnescape={true}
/> />
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>

View File

@@ -32,43 +32,34 @@ export const ContinuePage = () => {
cookieDomain, cookieDomain,
); );
const urlHref = url?.href; const handleRedirect = useCallback(() => {
hasRedirected.current = true;
setIsLoading(true);
window.location.assign(url!);
}, [url]);
const hasValidRedirect = valid && allowedProto; useEffect(() => {
const showUntrustedWarning = if (!isLoggedIn) {
hasValidRedirect && !trusted && !disableUiWarnings;
const showInsecureWarning =
hasValidRedirect && httpsDowngrade && !disableUiWarnings;
const shouldAutoRedirect =
isLoggedIn &&
hasValidRedirect &&
!showUntrustedWarning &&
!showInsecureWarning;
const redirectToTarget = useCallback(() => {
if (!urlHref || hasRedirected.current) {
return; return;
} }
hasRedirected.current = true; if (hasRedirected.current) {
window.location.assign(urlHref); return;
}, [urlHref]); }
const handleRedirect = useCallback(() => { if (
setIsLoading(true); (!valid || !allowedProto || !trusted || httpsDowngrade) &&
redirectToTarget(); !disableUiWarnings
}, [redirectToTarget]); ) {
useEffect(() => {
if (!shouldAutoRedirect) {
return; return;
} }
const auto = setTimeout(() => { const auto = setTimeout(() => {
redirectToTarget(); handleRedirect();
}, 100); }, 100);
const reveal = setTimeout(() => { const reveal = setTimeout(() => {
setIsLoading(false);
setShowRedirectButton(true); setShowRedirectButton(true);
}, 5000); }, 5000);
@@ -76,7 +67,18 @@ export const ContinuePage = () => {
clearTimeout(auto); clearTimeout(auto);
clearTimeout(reveal); clearTimeout(reveal);
}; };
}, [shouldAutoRedirect, redirectToTarget]); }, [
isLoggedIn,
hasRedirected,
valid,
allowedProto,
trusted,
httpsDowngrade,
disableUiWarnings,
setIsLoading,
handleRedirect,
setShowRedirectButton,
]);
if (!isLoggedIn) { if (!isLoggedIn) {
return ( return (
@@ -87,11 +89,11 @@ export const ContinuePage = () => {
); );
} }
if (!hasValidRedirect) { if (!valid || !allowedProto) {
return <Navigate to="/logout" replace />; return <Navigate to="/logout" replace />;
} }
if (showUntrustedWarning) { if (!trusted && !disableUiWarnings) {
return ( return (
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm"> <Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
<CardHeader> <CardHeader>
@@ -106,12 +108,13 @@ export const ContinuePage = () => {
code: <code />, code: <code />,
}} }}
values={{ cookieDomain }} values={{ cookieDomain }}
shouldUnescape={true}
/> />
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardFooter className="flex flex-col items-stretch gap-2"> <CardFooter className="flex flex-col items-stretch gap-2">
<Button <Button
onClick={handleRedirect} onClick={() => handleRedirect()}
loading={isLoading} loading={isLoading}
variant="destructive" variant="destructive"
> >
@@ -129,7 +132,7 @@ export const ContinuePage = () => {
); );
} }
if (showInsecureWarning) { if (httpsDowngrade && !disableUiWarnings) {
return ( return (
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm"> <Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
<CardHeader> <CardHeader>
@@ -148,7 +151,7 @@ export const ContinuePage = () => {
</CardHeader> </CardHeader>
<CardFooter className="flex flex-col items-stretch gap-2"> <CardFooter className="flex flex-col items-stretch gap-2">
<Button <Button
onClick={handleRedirect} onClick={() => handleRedirect()}
loading={isLoading} loading={isLoading}
variant="warning" variant="warning"
> >
@@ -176,7 +179,7 @@ export const ContinuePage = () => {
</CardHeader> </CardHeader>
{showRedirectButton && ( {showRedirectButton && (
<CardFooter className="flex flex-col items-stretch"> <CardFooter className="flex flex-col items-stretch">
<Button onClick={handleRedirect}> <Button onClick={() => handleRedirect()}>
{t("continueRedirectManually")} {t("continueRedirectManually")}
</Button> </Button>
</CardFooter> </CardFooter>

View File

@@ -67,6 +67,7 @@ export const LogoutPage = () => {
username: email, username: email,
provider: oauthName, provider: oauthName,
}} }}
shouldUnescape={true}
/> />
) : ( ) : (
<Trans <Trans
@@ -78,6 +79,7 @@ export const LogoutPage = () => {
values={{ values={{
username, username,
}} }}
shouldUnescape={true}
/> />
)} )}
</CardDescription> </CardDescription>