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 bluesky as a provider #281

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
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
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ It can also be set using environment variables:
- Authentik
- AWS Cognito
- Battle.net
- Bluesky (AT Protocol)
- Discord
- Dropbox
- Facebook
Expand Down Expand Up @@ -297,6 +298,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 @@ -704,26 +727,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 @@ -27,6 +27,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
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