跳到正文
DEV Community· Zeno Innovations·· 1 小時前AI 評分34

Zeno ID:自建的「使用 Google 登入」服務開放予所有開發者

We built our own "Sign in with Google" and opened it to every developer

AI 導讀

Zeno Innovations 將自建的 Zeno ID 開放予所有開發者,並將它建成完整的 OpenID Connect provider,讓應用程式可加入「Sign in with Zeno ID」登入按鈕。

正文

Cover image for We built our own "Sign in with Google" and opened it to every developer

Zeno Innovations

We run Zeno Innovations: hosting for websites and servers, Discord bots (JARVIS), an AI app, a Chrome extension and a webshop. Every one of them needed accounts, so we built Zeno ID: one account for all of it, like an Epic Games account.

Then we asked ourselves why we should keep it to our own apps. Zeno ID is now a full OpenID Connect provider, so any developer can add a "Sign in with Zeno ID" button to their app, the same way they'd add Google or GitHub.

Here's how to add it to a Supabase project. It takes about 5 minutes.

1. Start a custom provider in Supabase

Supabase supports custom OIDC providers. In your project go to:

Authentication → Sign In / Providers → Custom Providers → New Provider → Auto-discovery (OIDC)

  • Identifier: custom:zeno-id
  • Issuer URL: https://id.zeno-innovations.com

Copy the Callback URL it shows. It looks like https://<project>.supabase.co/auth/v1/callback.

2. Register your app

Go to Zeno ID apps, click Register an app, paste the callback URL as the return address and choose Server app. You get a client ID and a client secret.

3. Finish in Supabase

Paste the client ID and secret and click Create and enable provider.

4. Add the button

await supabase.auth.signInWithOAuth({
  provider: "custom:zeno-id",
  options: { redirectTo: window.location.origin },
});

That's it. People appear in auth.users like any other provider.

What's under the hood

  • Authorization code flow with PKCE (S256) and nonce
  • RS256-signed ID tokens, with keys published at /jwks
  • A pairwise sub: each app gets its own user id per person, so apps can't follow people across each other
  • A consent screen that shows exactly what the app gets, and people can revoke access at any time
  • Rotating refresh tokens with offline_access

It also works with Auth.js / NextAuth and any other OIDC library: give it the issuer and it finds the rest.

Full guide, including Next.js and the button: https://zeno-innovations.com/sign-in-with-zeno-id

We'd love feedback, especially from people who have built auth before. What would you want from a provider like this?

來源:DEV Community · dev.to