-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add @auth/astro framework library #9856
Open
TheOtterlord
wants to merge
54
commits into
nextauthjs:main
Choose a base branch
from
TheOtterlord:auth-astro
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
d559a15
Implement new version of @auth/astro
TheOtterlord 1da57c0
Add missed additions
TheOtterlord d57bf7b
Reimplement auth config with overrides, clean up types, fix other mis…
TheOtterlord 2ba14c9
Update packages/frameworks-astro/package.json
TheOtterlord d957b9b
Update packages/frameworks-astro/src/server.ts
TheOtterlord ba3fd40
Update types
TheOtterlord 653ea4f
Merge branch 'auth-astro' of https://github.com/TheOtterlord/authjs i…
TheOtterlord b74d6a8
Change baseURL to /auth, add framework redirect, add providers script…
TheOtterlord bc0019d
Docs changes
TheOtterlord db1c746
Merge branch 'main' of https://github.com/nextauthjs/next-auth into a…
TheOtterlord caf5979
Update server-side logic to use newer methods
TheOtterlord ff72a1e
Fix protocol & update docs reference
TheOtterlord 660b1da
Merge branch 'main' into auth-astro
TheOtterlord bab2a98
Fix protocol & update docs reference
TheOtterlord 89a2244
Merge branch 'main' into auth-astro
ndom91 009da21
chore: fix root pnpm-lock.yaml
ndom91 40c97f3
Discard changes to docs/docs/reference/index.md
ndom91 45e080f
Discard changes to docs/scripts/generate-manifest.mjs
ndom91 d64acf2
Discard changes to docs/static/img/frameworks/astro.svg
ndom91 981396e
Discard changes to docs/vercel.json
ndom91 7a1f49e
chore: fix package.json eslintIgnores
ndom91 80be2b5
Merge branch 'auth-astro' of github.com:TheOtterlord/authjs into auth…
ndom91 7698eb3
chore: more root package.json cleanup
ndom91 8c84008
chore: update root pnpm-lock.yaml
ndom91 a0ec246
chore: add README.md
ndom91 de08620
fix: rm misplaced api/[...auth] file in frameworks-astro dir
ndom91 afe69a5
fix: add build step and cleanup package.json
ndom91 ba8aa3f
Update Vite & restore injected route
TheOtterlord 0beb5ca
Delete lockfile
TheOtterlord 53af586
Update lockfile
TheOtterlord 2dfbbad
Actually fix lockfile & merge upstream/main into auth-astro
TheOtterlord 47bd52d
Undelete vscode file
TheOtterlord 64fa5fd
Fix linting
TheOtterlord 64ad2c6
Fix errors caused by linting
TheOtterlord 953650b
Merge from upstream/main
TheOtterlord fa8b9b8
merge
ThangHuuVu 8bce44b
Update pnpm-lock.yaml
ThangHuuVu 6920307
chore: linter
ThangHuuVu ef174e1
fix: get the dev app working
ThangHuuVu e98a0eb
fix: reference types
ThangHuuVu 015ffca
chore: rename getSession to auth
ThangHuuVu 0a493fe
chore: update config type
ThangHuuVu 822c64e
Merge branch 'main' into auth-astro
ThangHuuVu 444ec86
Update pnpm-lock.yaml
ThangHuuVu 33a83f1
chore: update deps
ThangHuuVu 099feeb
feat: relocate /api dir
ThangHuuVu 11ef712
fix: add astro typedoc config
ndom91 32913ae
fix: add astro sidebar name
ndom91 f88e2fc
Remove middleware.ts
TheOtterlord 5e4cfa3
Remove Astro 3 compatibility
TheOtterlord b8fb83a
Merge upstream/main into theotterlord/authjs
TheOtterlord cd3b8f5
Merge upstream/main into theotterlord/authjs
TheOtterlord 28978de
Add support for Astro 5
TheOtterlord 175dfa2
Merge upstream
TheOtterlord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# build output | ||
dist/ | ||
# generated types | ||
.astro/ | ||
|
||
# dependencies | ||
node_modules/ | ||
|
||
# logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
|
||
# environment variables | ||
.env | ||
.env.production | ||
|
||
# macOS-specific files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"recommendations": ["astro-build.astro-vscode"], | ||
"unwantedRecommendations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"command": "./node_modules/.bin/astro dev", | ||
"name": "Development server", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Astro Starter Kit: Minimal | ||
|
||
```sh | ||
npm create astro@latest -- --template minimal | ||
``` | ||
|
||
[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal) | ||
[](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal) | ||
[](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/minimal/devcontainer.json) | ||
|
||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun! | ||
|
||
## 🚀 Project Structure | ||
|
||
Inside of your Astro project, you'll see the following folders and files: | ||
|
||
```text | ||
/ | ||
├── public/ | ||
├── src/ | ||
│ └── pages/ | ||
│ └── index.astro | ||
└── package.json | ||
``` | ||
|
||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. | ||
|
||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. | ||
|
||
Any static assets, like images, can be placed in the `public/` directory. | ||
|
||
## 🧞 Commands | ||
|
||
All commands are run from the root of the project, from a terminal: | ||
|
||
| Command | Action | | ||
| :------------------------ | :----------------------------------------------- | | ||
| `npm install` | Installs dependencies | | ||
| `npm run dev` | Starts local dev server at `localhost:4321` | | ||
| `npm run build` | Build your production site to `./dist/` | | ||
| `npm run preview` | Preview your build locally, before deploying | | ||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | | ||
| `npm run astro -- --help` | Get help using the Astro CLI | | ||
|
||
## 👀 Want to learn more? | ||
|
||
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from "astro/config" | ||
import auth from "@auth/astro" | ||
|
||
import node from "@astrojs/node" | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [auth()], | ||
output: "server", | ||
adapter: node({ | ||
mode: "standalone", | ||
}), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from "@auth/astro/config" | ||
import GitHub from "@auth/astro/providers/github" | ||
|
||
export default defineConfig({ | ||
providers: [ | ||
GitHub({ | ||
clientId: import.meta.env.GITHUB_CLIENT_ID, | ||
clientSecret: import.meta.env.GITHUB_CLIENT_SECRET, | ||
}), | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "astro-auth-app", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"dev": "astro dev", | ||
"start": "astro dev", | ||
"build": "astro check && astro build", | ||
"preview": "astro preview", | ||
"astro": "astro" | ||
}, | ||
"dependencies": { | ||
"@astrojs/check": "^0.9.4", | ||
"@astrojs/node": "^9.0.0", | ||
"@auth/astro": "workspace:*", | ||
"astro": "^5.0.0", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference path="../.astro/types.d.ts" /> | ||
/// <reference types="astro/client" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
const { session } = Astro.locals | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta name="generator" content={Astro.generator} /> | ||
<title>Astro</title> | ||
</head> | ||
<body> | ||
<h1>Astro</h1> | ||
{ | ||
session ? ( | ||
<p>Hi {session?.user?.name}!</p> | ||
<button class="signout">Sign out</button> | ||
) : ( | ||
<button class="signin">Sign in</button> | ||
) | ||
} | ||
|
||
<p> | ||
<a href="/protected">Go to protected page</a> | ||
</p> | ||
|
||
<script> | ||
import { signIn, signOut } from '@auth/astro/client' | ||
|
||
document.querySelector('.signin')?.addEventListener('click', () => signIn('github')) | ||
document.querySelector('.signout')?.addEventListener('click', () => signOut()) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
const { session } = Astro.locals | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta name="generator" content={Astro.generator} /> | ||
<title>Astro</title> | ||
</head> | ||
<body> | ||
{ | ||
session ? ( | ||
<h1>Protected page</h1> | ||
<p> | ||
This is a protected content. You can access this content because you are signed in. | ||
</p> | ||
<p> | ||
<a href="/">Go to home</a> | ||
</p> | ||
) : ( | ||
<h1>Access Denied</h1> | ||
<p> | ||
<a href="/auth/signin">You must be signed in to view this page</a> | ||
</p> | ||
<p> | ||
<a href="/">Go to home</a> | ||
</p> | ||
) | ||
} | ||
|
||
<script> | ||
import { signIn, signOut } from '@auth/astro/client' | ||
|
||
document.querySelector('.signin')?.addEventListener('click', () => signIn('github')) | ||
document.querySelector('.signout')?.addEventListener('click', () => signOut()) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "astro/tsconfigs/strict" | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# build output | ||
dist/ | ||
# generated types | ||
.astro/ | ||
|
||
# dependencies | ||
node_modules/ | ||
|
||
# logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
|
||
# environment variables | ||
.env | ||
.env.production | ||
|
||
# macOS-specific files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"recommendations": ["astro-build.astro-vscode"], | ||
"unwantedRecommendations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"command": "./node_modules/.bin/astro dev", | ||
"name": "Development server", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Astro Starter Kit: Minimal | ||
|
||
```sh | ||
npm create astro@latest -- --template minimal | ||
``` | ||
|
||
[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal) | ||
[](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal) | ||
[](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/minimal/devcontainer.json) | ||
|
||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun! | ||
|
||
## 🚀 Project Structure | ||
|
||
Inside of your Astro project, you'll see the following folders and files: | ||
|
||
```text | ||
/ | ||
├── public/ | ||
├── src/ | ||
│ └── pages/ | ||
│ └── index.astro | ||
└── package.json | ||
``` | ||
|
||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. | ||
|
||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. | ||
|
||
Any static assets, like images, can be placed in the `public/` directory. | ||
|
||
## 🧞 Commands | ||
|
||
All commands are run from the root of the project, from a terminal: | ||
|
||
| Command | Action | | ||
| :------------------------ | :----------------------------------------------- | | ||
| `npm install` | Installs dependencies | | ||
| `npm run dev` | Starts local dev server at `localhost:4321` | | ||
| `npm run build` | Build your production site to `./dist/` | | ||
| `npm run preview` | Preview your build locally, before deploying | | ||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | | ||
| `npm run astro -- --help` | Get help using the Astro CLI | | ||
|
||
## 👀 Want to learn more? | ||
|
||
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from "astro/config" | ||
import auth from "@auth/astro" | ||
|
||
import node from "@astrojs/node" | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [auth()], | ||
output: "server", | ||
adapter: node({ | ||
mode: "standalone", | ||
}), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from "@auth/astro/config" | ||
import GitHub from "@auth/astro/providers/github" | ||
|
||
export default defineConfig({ | ||
providers: [ | ||
GitHub({ | ||
clientId: import.meta.env.GITHUB_CLIENT_ID, | ||
clientSecret: import.meta.env.GITHUB_CLIENT_SECRET, | ||
}), | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "astro", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"dev": "astro dev", | ||
"start": "astro dev", | ||
"build": "astro check && astro build", | ||
"preview": "astro preview", | ||
"astro": "astro" | ||
}, | ||
"dependencies": { | ||
"@astrojs/check": "^0.9.4", | ||
"@astrojs/node": "^9.0.0", | ||
"@auth/astro": "^0.1.0", | ||
"astro": "^5.0.0", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="astro/client" /> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set the
include
andexclude
fields as recommended by Astro in the TypeScript guide