Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/web/src/features/auth/auth-parts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { Button, IconButton, Input, toast, type InputProps } from '@potluck/ui'
import { useQuery } from '@tanstack/react-query'
import { Eye, EyeOff } from 'lucide-react'
import { forwardRef, useState } from 'react'
import { HELP_PAGES } from '@/features/help/topics'
import { authCallbackUrl } from '@/lib/auth'
import { docsUrl } from '@/lib/docs'
import { errorMessage } from '@/lib/errors'
import { supabase } from '@/lib/supabase'

Expand Down Expand Up @@ -135,3 +137,20 @@ export function CheckEmail({
</div>
)
}

/** Potluck has no separate terms: the guide's privacy page says what is kept and who sees it. */
export function PrivacyNote() {
return (
<p className="text-xs">
{t('auth.signUp.privacy')}{' '}
<a
href={docsUrl(HELP_PAGES.privacy)}
target="_blank"
rel="noopener"
className="font-semibold text-ink underline decoration-tomato decoration-2 underline-offset-4"
>
{t('auth.signUp.privacyLink')} <span className="sr-only">({t('help.newTab')})</span>
</a>
</p>
)
}
11 changes: 11 additions & 0 deletions apps/web/src/features/auth/sign-in-page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { t } from '@potluck/i18n'
import { Toaster } from '@potluck/ui'
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { HELP_PAGES } from '@/features/help/topics'
import { confirmSession, endEndedSession } from '@/lib/auth'
import { docsUrl } from '@/lib/docs'
import { renderWithProviders } from '@/test/render'
import { authCallsTo, resetDb, respondAuth } from '@/test/supabase'
import { SignInPage } from './sign-in-page'
Expand Down Expand Up @@ -73,6 +75,15 @@ describe('SignInPage', () => {
expect(await screen.findByText(t('auth.signIn.sessionEnded'))).toBeInTheDocument()
})

it("links to the guide's privacy page in a new tab", async () => {
renderPage()
const link = await screen.findByRole('link', {
name: `${t('auth.signUp.privacyLink')} (${t('help.newTab')})`,
})
expect(link).toHaveAttribute('href', docsUrl(HELP_PAGES.privacy))
expect(link).toHaveAttribute('target', '_blank')
})

it('never redirects off site after signing in', async () => {
const { router } = renderPage({ redirect: 'https://evil.example' })
await fill('[email protected]', 'hunter22')
Expand Down
25 changes: 14 additions & 11 deletions apps/web/src/features/auth/sign-in-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { errorMessage } from '@/lib/errors'
import { detectTimezone } from '@/lib/locale'
import { supabase } from '@/lib/supabase'
import { AuthLayout } from './auth-layout'
import { CheckEmail, OAuthButtons, PasswordInput } from './auth-parts'
import { CheckEmail, OAuthButtons, PasswordInput, PrivacyNote } from './auth-parts'

export interface AuthPageProps {
redirect?: string
Expand Down Expand Up @@ -86,16 +86,19 @@ export function SignInPage({ redirect, notice }: AuthPageProps) {
subtitle={t('auth.signIn.subtitle')}
notice={notice ?? (ended ? t('auth.signIn.sessionEnded') : undefined)}
footer={
<p>
{t('auth.signIn.noAccount')}{' '}
<Link
to="/sign-up"
search={{ redirect }}
className="font-semibold text-ink underline decoration-tomato decoration-2 underline-offset-4"
>
{t('auth.signIn.createAccount')}
</Link>
</p>
<div className="grid gap-3">
<p>
{t('auth.signIn.noAccount')}{' '}
<Link
to="/sign-up"
search={{ redirect }}
className="font-semibold text-ink underline decoration-tomato decoration-2 underline-offset-4"
>
{t('auth.signIn.createAccount')}
</Link>
</p>
<PrivacyNote />
</div>
}
>
<OAuthButtons redirect={target} />
Expand Down
17 changes: 2 additions & 15 deletions apps/web/src/features/auth/sign-up-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { Link, useNavigate } from '@tanstack/react-router'
import { currentLocale, t } from '@potluck/i18n'
import { Button, Field, Input, toast } from '@potluck/ui'
import { useState, type FormEvent } from 'react'
import { HELP_PAGES } from '@/features/help/topics'
import { authCallbackUrl, safeRedirect } from '@/lib/auth'
import { docsUrl } from '@/lib/docs'
import { errorMessage } from '@/lib/errors'
import { detectTimezone } from '@/lib/locale'
import { supabase } from '@/lib/supabase'
import { AuthLayout } from './auth-layout'
import { CheckEmail, OAuthButtons, PasswordInput } from './auth-parts'
import { CheckEmail, OAuthButtons, PasswordInput, PrivacyNote } from './auth-parts'
import type { AuthPageProps } from './sign-in-page'

export const MIN_PASSWORD = 8
Expand Down Expand Up @@ -92,18 +90,7 @@ export function SignUpPage({ redirect, notice }: AuthPageProps) {
{t('auth.signUp.signInLink')}
</Link>
</p>
{/* Potluck has no separate terms: the guide's privacy page says what is kept and shown. */}
<p className="text-xs">
{t('auth.signUp.privacy')}{' '}
<a
href={docsUrl(HELP_PAGES.privacy)}
target="_blank"
rel="noopener"
className="font-semibold text-ink underline decoration-tomato decoration-2 underline-offset-4"
>
{t('auth.signUp.privacyLink')} <span className="sr-only">({t('help.newTab')})</span>
</a>
</p>
<PrivacyNote />
</div>
}
>
Expand Down
10 changes: 10 additions & 0 deletions apps/web/src/features/shell/landing-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button } from '@potluck/ui'
import { Link } from '@tanstack/react-router'
import { ArrowRightLeft, CalendarHeart, Receipt } from 'lucide-react'
import { lazy, Suspense, type ReactNode } from 'react'
import { HELP_PAGES } from '@/features/help/topics'
import { docsUrl } from '@/lib/docs'
import { Wordmark } from './brand'
import { heroFrame } from './hero-frame'
Expand Down Expand Up @@ -150,6 +151,15 @@ export function LandingPage() {
{t('help.guide')} <span className="sr-only">({t('help.newTab')})</span>
</a>
{'. '}
<a
href={docsUrl(HELP_PAGES.privacy)}
target="_blank"
rel="noopener"
className="font-semibold text-ink underline decoration-tomato decoration-2 underline-offset-4"
>
{t('app.landing.footer.privacy')} <span className="sr-only">({t('help.newTab')})</span>
</a>
{'. '}
<a
href="https://fermulate.com"
className="font-semibold text-ink underline decoration-tomato decoration-2 underline-offset-4"
Expand Down
5 changes: 3 additions & 2 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Set these under **Settings > Secrets and variables > Actions**. Variables are vi
| `SUPABASE_DB_PASSWORD` | Optional. The pinned CLI signs in with a temporary role made from the access token |
| `SUPABASE_URL` | `keepalive.yml` daily ping |
| `SUPABASE_PUBLISHABLE_KEY` | `keepalive.yml` daily ping |
| `SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET` | `supabase config push`, once Google sign in is enabled (`production` environment secret) |
| `SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET` | `supabase config push` for Google sign in, which is on (`production` environment secret) |
| `SUPABASE_AUTH_EXTERNAL_APPLE_SECRET` | `supabase config push`, once Apple sign in is enabled (`production` environment secret) |

Missing credentials do not fail the workflow. Without `CLOUDFLARE_API_TOKEN` the web job builds and skips the upload. Without `SUPABASE_ACCESS_TOKEN` the `migrate` job logs a notice and skips. That keeps forks green.
Expand All @@ -65,7 +65,8 @@ Migrations go first so the database is never behind the client. Because migratio
`supabase/config.toml` holds local settings at the top and production overrides under `[remotes.production]`. `supabase config push` applies the overrides when the linked project's ref matches `remotes.production.project_id`. Production differs from local in:

- `auth.site_url` is the custom domain. `additional_redirect_urls`: the custom domain, the old workers.dev URL, every `*-potluck.potluck-web.workers.dev` preview, and localhost.
- `minimum_password_length = 8`, email confirmations on, one email per 60 s per address.
- `minimum_password_length = 8`, email confirmations on (seats and email-bound invites rely on it, see [security](security.md#sign-in)), one email per 60 s per address.
- Google sign in on (`[remotes.production.auth.external.google]`, client secret from `SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET`).
- Security notice email subjects (password, email address and verification method changes) are Supabase's defaults, because the built-in sender refuses custom ones. They go once a custom SMTP provider is set ([launch checklist](launch-checklist.md#3-email)).
- TOTP MFA enroll and verify on.
- Pooler sizes, and the vector bucket feature off.
Expand Down
6 changes: 4 additions & 2 deletions docs/launch-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The `migrate` job skips until `SUPABASE_ACCESS_TOKEN` exists (Supabase dashboard

### 3. Email

Auth email uses Supabase's built-in sender, which is rate limited and meant for testing. Email confirmation is on in production, so sign-ups beyond the limit wait. Notification email (new expenses, payments, the monthly summary, with one-click unsubscribe) is built but off: `app_config.email_notifications` is `false`, so nothing is queued. To send from `fermulate.com`:
Auth email uses Supabase's built-in sender, which is rate limited and meant for testing. Email confirmation is on in production and must stay on (seats and email-bound invites trust a confirmed address). The built-in sender only delivers to members of the Supabase team, so until custom SMTP is set, people signing up with email never get their confirmation link; Google sign in works without it. Notification email (new expenses, payments, the monthly summary, with one-click unsubscribe) is built but off: `app_config.email_notifications` is `false`, so nothing is queued. To send from `fermulate.com`:

1. Create a Resend account and verify the domain.
2. Supabase dashboard, Authentication, SMTP settings: enter Resend's SMTP details (auth email).
Expand All @@ -61,7 +61,9 @@ Both buttons are hidden behind `app_config` flags (`google_auth`, `apple_auth`).
secret = "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET)"
```

4. `update public.app_config set value = 'true' where key = 'google_auth';` (or `apple_auth`).
4. Turn the flag on in a migration, `update public.app_config set value = 'true' where key = 'google_auth';` (or `apple_auth`), and set it back to `false` in `supabase/seed.sql`, so local stacks, which have no provider, keep the button hidden.

Google is on (client "Potluck web (production)" in the Google Cloud project `fermulate-potluck-prod`, flag set by `20261116230000_google_sign_in_on.sql`). Apple is still off.

### 5. Calendar import

Expand Down
2 changes: 1 addition & 1 deletion docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ These are real today. Each should become an issue.

## Sign in

- **Methods.** Email and password, a magic link, and Google or Apple once their flags are on. Production requires a confirmed email before the first sign in.
- **Methods.** Email and password, a magic link, Google, and Apple once its flag is on. Production requires a confirmed email before the first sign in: seats and email-bound invites trust a confirmed address, so turning confirmation off would let anyone claim another person's seat by signing up with their email.
- **Two-step sign in.** An authenticator app (TOTP) from the Me page. Signing in with any method then asks for a code. The database enforces it ([ADR 13](adr/0013-two-step-sign-in-enforced-in-the-database.md)): until the code is in, every REST and RPC call fails with `mfa_required`, Storage reads and writes nothing in any bucket, and Realtime sends nothing. Supabase Auth refuses that session's email, password and factor changes. Turning it off needs a fresh code.
- **Recovery codes.** Ten one-time codes are shown once at setup (and again whenever they are replaced); the dialog only closes once the person says they saved them. They are stored as SHA-256 hashes, which is enough because they are random. One code, together with the first sign in step, removes the authenticator so the person can set it up again. Five tries per account per fifteen minutes, then `too_many_attempts`. Turning two-step sign in off clears them. Without the codes, an operator has to remove the factor by hand after checking who is asking.
- **Changing the email** sends a link to the old and to the new address (`double_confirm_changes`); in production the switch happens only when both are opened, so a stolen session cannot quietly move the account to another inbox. (The local stack auto-confirms email, and Supabase then takes either link as enough.) A pending change can be called off from Me (`cancel-email-change`), which voids its links.
Expand Down
2 changes: 1 addition & 1 deletion docs/splitwise-parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ What Splitwise Free holds back today: 4 new expenses per day, ads, and the Pro f
| App passcode lock | Free (apps) | skip | the PWA uses the device lock; revisit for the native app |
| Two-factor authentication | not in Splitwise | exists | authenticator app, recovery codes, enforced in the database (ADR 13) |
| Log out on all devices | Free | exists | also after a password change, for every other device |
| Sign in with Google (Splitwise also has Facebook) | Free | partial | Google and Apple built, flagged off until OAuth clients exist |
| Sign in with Google (Splitwise also has Facebook) | Free | partial | Google on; Apple built, flagged off until its OAuth client exists |
| Merge two accounts | Free (support) | skip | rare; handle by hand if it comes up |
| Delete account | Free | exists | tombstones the profile, shared history kept |
| Download my data | Free by emailing support; JSON self-serve is Pro | exists | Me, Your data: JSON backup and spreadsheets, self-serve (Batch 5) |
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/de/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const app = {
license: 'Freie Software unter der AGPL-3.0.',
source: 'Quellcode',
madeBy: 'Ein Projekt von Fermulate',
privacy: 'Datenschutz',
},
},
offline: {
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/en/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const app = {
license: 'Free software under the AGPL-3.0.',
source: 'Source code',
madeBy: 'A Fermulate project',
privacy: 'Privacy',
},
},
offline: {
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/es/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const app = {
license: 'Software libre bajo la AGPL-3.0.',
source: 'Código fuente',
madeBy: 'Un proyecto de Fermulate',
privacy: 'Privacidad',
},
},
offline: {
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/fr/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const app = {
license: 'Logiciel libre sous licence AGPL-3.0.',
source: 'Code source',
madeBy: 'Un projet Fermulate',
privacy: 'Confidentialité',
},
},
offline: {
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/pt/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const app = {
license: 'Software livre sob a AGPL-3.0.',
source: 'Código-fonte',
madeBy: 'Um projeto da Fermulate',
privacy: 'Privacidade',
},
},
offline: {
Expand Down
6 changes: 6 additions & 0 deletions supabase/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,12 @@ verify_enabled = true
[remotes.production.auth.sms]
enable_confirmations = true

[remotes.production.auth.external.google]
enabled = true
client_id = "939770238734-0hf3vsdsq1uv7n01mvfb0j8pu248j6un.apps.googleusercontent.com"
# DO NOT commit the secret: the deploy passes it from the GitHub production environment.
secret = "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET)"

[remotes.production.db.pooler]
default_pool_size = 15
max_client_conn = 200
Expand Down
3 changes: 3 additions & 0 deletions supabase/migrations/20261116230000_google_sign_in_on.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Google sign in is configured for production (supabase/config.toml, [remotes.production.auth.external.google]),
-- so show its button. supabase/seed.sql turns it back off for local stacks, which have no Google provider.
update public.app_config set value = 'true'::jsonb where key = 'google_auth';
4 changes: 4 additions & 0 deletions supabase/seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,7 @@ update public.activity a set created_at = ev.created_at
from public.events ev where a.verb = 'event.created' and a.subject_id = ev.id;

select set_config('request.jwt.claims', '', false);

-- Local stacks have no Google provider, so keep its button hidden here
-- (20261116230000_google_sign_in_on.sql turns it on for production).
update public.app_config set value = 'false'::jsonb where key = 'google_auth';
Loading