{"id":26728306,"url":"https://github.com/oliverspeir/astro-d1-magiclink","last_synced_at":"2026-04-25T16:33:53.596Z","repository":{"id":284715798,"uuid":"955784488","full_name":"OliverSpeir/astro-d1-magiclink","owner":"OliverSpeir","description":"Magic link auth based on Lucia-auth Astro Actions and Cloudflare D1","archived":false,"fork":false,"pushed_at":"2025-03-27T09:32:40.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T10:25:14.927Z","etag":null,"topics":["astro","d1-database","lucia-auth","magic-link-authentication","passwordless-authentication"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OliverSpeir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-27T07:34:34.000Z","updated_at":"2025-03-27T09:32:43.000Z","dependencies_parsed_at":"2025-03-27T10:25:19.128Z","dependency_job_id":"e526d654-aa5b-4ccb-8996-cd2c1473eb09","html_url":"https://github.com/OliverSpeir/astro-d1-magiclink","commit_stats":null,"previous_names":["oliverspeir/astro-d1-magiclink"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverSpeir%2Fastro-d1-magiclink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverSpeir%2Fastro-d1-magiclink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverSpeir%2Fastro-d1-magiclink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverSpeir%2Fastro-d1-magiclink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OliverSpeir","download_url":"https://codeload.github.com/OliverSpeir/astro-d1-magiclink/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245932601,"owners_count":20696091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astro","d1-database","lucia-auth","magic-link-authentication","passwordless-authentication"],"created_at":"2025-03-27T22:22:59.824Z","updated_at":"2026-04-25T16:33:53.583Z","avatar_url":"https://github.com/OliverSpeir.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Astro D1 Actions Magic Link Auth\n\nInspired / based on [Lucia-auth basic API](https://lucia-auth.com/sessions/basic-api/) sqlite\n\n\u003e [!WARNING]\n\u003e I made this to explore actions, the lucia guide and D1, do not use this or magic links :)\n\n## Tech\n\n1. [Cloudflare D1](https://developers.cloudflare.com/d1/)\n2. [Resend](https://resend.com/)\n3. [Astro Actions](https://docs.astro.build/en/guides/actions/)\n4. [Astro Scoped Styles](https://docs.astro.build/en/guides/styling/#scoped-styles)\n5. [Astro on-demand rendering](https://docs.astro.build/en/guides/on-demand-rendering/)\n\n## Walkthrough\n\n- Creates an [`@auth`](./src/lib/auth/) API with useful functions, and requires zero deps.\n- Handles sessions within [middleware](./src/middleware.ts) for certain routes, but relies on those routes to protect themselves\n- Creates a set of actions ([actions.auth](./src/actions/auth.ts)) which use the [`@auth` API](./src/lib/auth)\n- Attempts to be [Progressive Enhancement](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement), meaning requires zero JS to work, meaning all actions are submit via html forms\n- Attempts to rate limit emails in the [auth actions](./src/actions/auth.ts) based on the token createdAt time\n- Uses [schema.sql](./src/lib/db/schema.sql) and creates indexes in attempt to improve performance (didn't test if these help)\n- Attempts to provide opaque messaging to prevent enumeration attacks on existing accounts\n- Will not sign in if user has not signed up, but will sign in if user has already signed up and tries to sign up again\n  - not 100% sure about this pattern but maybe supports some special sign up stuff in future, but does create friction if user doesn't realize they must sign up first\n- Has a non action based [endpoint for verification](./src/pages/login/verify.ts), looked into having it use actions but it just didn't feel right, this is my first actions project\n\n## Dev Experience / Deploying\n\n- Uses Astro Dev server, and wrangler cli\n- `wrangler types \u0026\u0026 astro dev`\n- `wrangler d1 create magic-links-prod`\n- `wrangler d1 execute magic-links-prod --local --file=./src/lib/db/schema.sql` for dev server\n- `wrangler d1 execute magic-links-prod --remote --file=./src/lib/db/schema.sql` in prod from cli\n- Secrets added via dashboard in prod (`RESEND_API_KEY`) \n  - View project -\u003e settings -\u003e variables and secrets -\u003e add secret and redeploy\n- Didn't bother with local or preview DB for dev\n- Created a resend account and tested via the onboarding email (which can only send to your account's email)\n\n## Notes\n\nThis project made me excited for [Astro Sessions](https://docs.astro.build/en/reference/experimental-flags/sessions/) and things like [laravel's flash data](https://laravel.com/docs/12.x/session#flash-data)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverspeir%2Fastro-d1-magiclink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliverspeir%2Fastro-d1-magiclink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverspeir%2Fastro-d1-magiclink/lists"}