Skip to content

Commit

Permalink
feat: add bluesky as a provider (#281)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Chopin <[email protected]>
Co-authored-by: Sébastien Chopin <[email protected]>
  • Loading branch information
3 people authored Feb 5, 2025
1 parent f9d8e13 commit 24cf95f
Show file tree
Hide file tree
Showing 15 changed files with 3,266 additions and 1,111 deletions.
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ It can also be set using environment variables:
- Authentik
- AWS Cognito
- Battle.net
- Bluesky (AT Protocol)
- Discord
- Dropbox
- Facebook
Expand Down Expand Up @@ -304,6 +305,28 @@ export default defineNuxtConfig({
})
```

### AT Protocol

Social networks that rely on AT Protocol (e.g., Bluesky) slightly differ from a regular OAuth flow.

To enable OAuth with AT Protocol, you need to:

1. Install the peer dependencies:

```bash
npx nypm i @atproto/oauth-client-node @atproto/api
```

2. Enable it in your `nuxt.config.ts`

```ts
export default defineNuxtConfig({
auth: {
atproto: true
}
})
```

### WebAuthn (passkey)

WebAuthn (Web Authentication) is a web standard that enhances security by replacing passwords with passkeys using public key cryptography. Users can authenticate with biometric data (like fingerprints or facial recognition) or physical devices (like USB keys), reducing the risk of phishing and password breaches. This approach offers a more secure and user-friendly authentication method, supported by major browsers and platforms.
Expand Down Expand Up @@ -711,26 +734,26 @@ Checkout the [`SessionConfig`](https://github.com/unjs/h3/blob/c04c458810e34eb15

```bash
# Install dependencies
npm install
pnpm install

# Generate type stubs
npm run dev:prepare
pnpm run dev:prepare

# Develop with the playground
npm run dev
pnpm run dev

# Build the playground
npm run dev:build
pnpm run dev:build

# Run ESLint
npm run lint
pnpm run lint

# Run Vitest
npm run test
npm run test:watch
pnpm run test
pnpm run test:watch

# Release new version
npm run release
pnpm run release
```

<!-- Badges -->
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,22 @@
},
"peerDependencies": {
"@simplewebauthn/browser": "^11.0.0",
"@simplewebauthn/server": "^11.0.0"
"@simplewebauthn/server": "^11.0.0",
"@atproto/oauth-client-node": "^0.2.0",
"@atproto/api": "^0.13.15"
},
"peerDependenciesMeta": {
"@simplewebauthn/browser": {
"optional": true
},
"@simplewebauthn/server": {
"optional": true
},
"@atproto/oauth-client-node": {
"optional": true
},
"@atproto/api": {
"optional": true
}
},
"devDependencies": {
Expand Down
16 changes: 16 additions & 0 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ const providers = computed(() =>
disabled: Boolean(user.value?.github),
icon: 'i-simple-icons-github',
},
{
label: user.value?.bluesky || 'Bluesky',
click() {
const handle = prompt('Enter your Bluesky handle')
if (handle) {
navigateTo({
path: '/auth/bluesky',
query: { handle },
}, {
external: true,
})
}
},
disabled: Boolean(user.value?.bluesky),
icon: 'i-simple-icons-bluesky',
},
{
label: user.value?.gitlab || 'GitLab',
to: '/auth/gitlab',
Expand Down
1 change: 1 addition & 0 deletions playground/auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare module '#auth-utils' {
interface User {
bluesky?: string
webauthn?: string
email?: string
password?: string
Expand Down
1 change: 1 addition & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ export default defineNuxtConfig({
},
auth: {
webAuthn: true,
atproto: true,
},
})
12 changes: 12 additions & 0 deletions playground/server/routes/auth/bluesky.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default defineOAuthBlueskyEventHandler({
async onSuccess(event, { user }) {
await setUserSession(event, {
user: {
bluesky: user.did,
},
loggedInAt: Date.now(),
})

return sendRedirect(event, '/')
},
})
Loading

0 comments on commit 24cf95f

Please sign in to comment.