Skip to content
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
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d559a15
Implement new version of @auth/astro
TheOtterlord Jan 30, 2024
1da57c0
Add missed additions
TheOtterlord Jan 30, 2024
d57bf7b
Reimplement auth config with overrides, clean up types, fix other mis…
TheOtterlord Jan 30, 2024
2ba14c9
Update packages/frameworks-astro/package.json
TheOtterlord Jan 31, 2024
d957b9b
Update packages/frameworks-astro/src/server.ts
TheOtterlord Jan 31, 2024
ba3fd40
Update types
TheOtterlord Jan 31, 2024
653ea4f
Merge branch 'auth-astro' of https://github.com/TheOtterlord/authjs i…
TheOtterlord Jan 31, 2024
b74d6a8
Change baseURL to /auth, add framework redirect, add providers script…
TheOtterlord Jan 31, 2024
bc0019d
Docs changes
TheOtterlord Mar 13, 2024
db1c746
Merge branch 'main' of https://github.com/nextauthjs/next-auth into a…
TheOtterlord Mar 13, 2024
caf5979
Update server-side logic to use newer methods
TheOtterlord Mar 17, 2024
ff72a1e
Fix protocol & update docs reference
TheOtterlord Mar 17, 2024
660b1da
Merge branch 'main' into auth-astro
TheOtterlord Mar 17, 2024
bab2a98
Fix protocol & update docs reference
TheOtterlord Mar 17, 2024
89a2244
Merge branch 'main' into auth-astro
ndom91 Apr 8, 2024
009da21
chore: fix root pnpm-lock.yaml
ndom91 Apr 26, 2024
40c97f3
Discard changes to docs/docs/reference/index.md
ndom91 Apr 26, 2024
45e080f
Discard changes to docs/scripts/generate-manifest.mjs
ndom91 Apr 26, 2024
d64acf2
Discard changes to docs/static/img/frameworks/astro.svg
ndom91 Apr 26, 2024
981396e
Discard changes to docs/vercel.json
ndom91 Apr 26, 2024
7a1f49e
chore: fix package.json eslintIgnores
ndom91 Apr 26, 2024
80be2b5
Merge branch 'auth-astro' of github.com:TheOtterlord/authjs into auth…
ndom91 Apr 26, 2024
7698eb3
chore: more root package.json cleanup
ndom91 Apr 26, 2024
8c84008
chore: update root pnpm-lock.yaml
ndom91 Apr 26, 2024
a0ec246
chore: add README.md
ndom91 Apr 26, 2024
de08620
fix: rm misplaced api/[...auth] file in frameworks-astro dir
ndom91 Apr 26, 2024
afe69a5
fix: add build step and cleanup package.json
ndom91 Apr 26, 2024
ba8aa3f
Update Vite & restore injected route
TheOtterlord Apr 26, 2024
0beb5ca
Delete lockfile
TheOtterlord Apr 26, 2024
53af586
Update lockfile
TheOtterlord Apr 26, 2024
2dfbbad
Actually fix lockfile & merge upstream/main into auth-astro
TheOtterlord Apr 26, 2024
47bd52d
Undelete vscode file
TheOtterlord Apr 26, 2024
64fa5fd
Fix linting
TheOtterlord Apr 26, 2024
64ad2c6
Fix errors caused by linting
TheOtterlord Apr 26, 2024
953650b
Merge from upstream/main
TheOtterlord Apr 28, 2024
fa8b9b8
merge
ThangHuuVu Oct 8, 2024
8bce44b
Update pnpm-lock.yaml
ThangHuuVu Oct 8, 2024
6920307
chore: linter
ThangHuuVu Oct 8, 2024
ef174e1
fix: get the dev app working
ThangHuuVu Oct 8, 2024
e98a0eb
fix: reference types
ThangHuuVu Oct 8, 2024
015ffca
chore: rename getSession to auth
ThangHuuVu Oct 8, 2024
0a493fe
chore: update config type
ThangHuuVu Oct 8, 2024
822c64e
Merge branch 'main' into auth-astro
ThangHuuVu Oct 13, 2024
444ec86
Update pnpm-lock.yaml
ThangHuuVu Oct 13, 2024
33a83f1
chore: update deps
ThangHuuVu Oct 13, 2024
099feeb
feat: relocate /api dir
ThangHuuVu Oct 13, 2024
11ef712
fix: add astro typedoc config
ndom91 Oct 19, 2024
32913ae
fix: add astro sidebar name
ndom91 Oct 19, 2024
f88e2fc
Remove middleware.ts
TheOtterlord Oct 19, 2024
5e4cfa3
Remove Astro 3 compatibility
TheOtterlord Oct 19, 2024
b8fb83a
Merge upstream/main into theotterlord/authjs
TheOtterlord Oct 19, 2024
cd3b8f5
Merge upstream/main into theotterlord/authjs
TheOtterlord Oct 30, 2024
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
1 change: 1 addition & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# https://github.com/actions/labeler#create-githublabeleryml
astro: ["packages/frameworks-astro/**/*"]
adapters: ["packages/core/src/adapters.ts", "packages/adapter-*/**/*"]
core: ["packages/core/src/**/*"]
azure-tables: ["packages/adapter-azure-tables/**/*"]
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ docs/docs/reference/sveltekit
# SolidStart
docs/docs/reference/solidstart

# Astro
docs/docs/reference/astro

# Express
docs/docs/reference/express
Expand Down
21 changes: 21 additions & 0 deletions apps/dev/astro/.gitignore
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
4 changes: 4 additions & 0 deletions apps/dev/astro/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions apps/dev/astro/.vscode/launch.json
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"
}
]
}
47 changes: 47 additions & 0 deletions apps/dev/astro/README.md
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
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](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).
13 changes: 13 additions & 0 deletions apps/dev/astro/astro.config.mjs
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"
})
});
12 changes: 12 additions & 0 deletions apps/dev/astro/auth.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from '@auth/astro/config'
import type { Provider } from '@auth/core/providers'
import GitHub from '@auth/core/providers/github'

export default defineConfig({
providers: [
GitHub({
clientId: import.meta.env.GITHUB_CLIENT_ID,
clientSecret: import.meta.env.GITHUB_CLIENT_SECRET,
}) as Provider,
TheOtterlord marked this conversation as resolved.
Show resolved Hide resolved
]
})
20 changes: 20 additions & 0 deletions apps/dev/astro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"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.4.1",
"@astrojs/node": "^8.1.0",
"@auth/astro": "workspace:*",
"@auth/core": "workspace:*",
"astro": "^4.2.5",
"typescript": "^5.3.3"
}
}
9 changes: 9 additions & 0 deletions apps/dev/astro/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/dev/astro/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
35 changes: 35 additions & 0 deletions apps/dev/astro/src/pages/index.astro
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>
41 changes: 41 additions & 0 deletions apps/dev/astro/src/pages/protected.astro
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="/api/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>
3 changes: 3 additions & 0 deletions apps/dev/astro/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/strict"
}
21 changes: 21 additions & 0 deletions apps/examples/astro/.gitignore
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
4 changes: 4 additions & 0 deletions apps/examples/astro/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions apps/examples/astro/.vscode/launch.json
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"
}
]
}
47 changes: 47 additions & 0 deletions apps/examples/astro/README.md
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
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](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).
13 changes: 13 additions & 0 deletions apps/examples/astro/astro.config.mjs
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"
})
});
12 changes: 12 additions & 0 deletions apps/examples/astro/auth.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from '@auth/astro/config'
import type { Provider } from '@auth/core/providers'
import GitHub from '@auth/core/providers/github'

export default defineConfig({
providers: [
GitHub({
clientId: import.meta.env.GITHUB_CLIENT_ID,
clientSecret: import.meta.env.GITHUB_CLIENT_SECRET,
}) as Provider,
]
})
20 changes: 20 additions & 0 deletions apps/examples/astro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"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.4.1",
"@astrojs/node": "^8.1.0",
"@auth/astro": "^0.1.0",
"@auth/core": "^0.24.0",
"astro": "^4.2.5",
"typescript": "^5.3.3"
}
}
9 changes: 9 additions & 0 deletions apps/examples/astro/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/examples/astro/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
Loading
Loading