Passer au contenu principal
FIM One prend en charge la connexion sociale via GitHub, Google, Discord et Feishu (Lark). Tout fournisseur dont les identifiants sont présents dans l’environnement affiche automatiquement un bouton de connexion sur la page de connexion — aucune modification de code requise. Modèle d’URL de rappel — enregistrez cette URL exacte dans la console développeur de chaque fournisseur :
API_BASE_URL est l’adresse accessible de l’extérieur du backend FIM One. Exemples :

GitHub

Developer console: https://github.com/settings/developers
  1. Click OAuth Apps → New OAuth App.
  2. Fill in:
    • Application name — any name (e.g. FIM One)
    • Homepage URL — your frontend URL (e.g. https://yourdomain.com)
    • Authorization callback URL — https://yourdomain.com/api/auth/oauth/github/callback
  3. Click Register application, then click Generate a new client secret.
  4. Copy the Client ID and the generated Client Secret into your .env.
Scopes requested automatically: read:user, user:email GitHub accounts with a private primary email are handled correctly — FIM One fetches the primary email from /user/emails (not the public profile email) and records whether GitHub marks it verified.

Google

Console de développement : https://console.cloud.google.com/apis/credentials
  1. Cliquez sur + CREATE CREDENTIALS → OAuth client ID.
  2. Si vous y êtes invité, configurez d’abord l’OAuth consent screen (définissez User Type sur “External” pour les applications personnelles/publiques).
  3. Définissez Application type sur Web application.
  4. Sous Authorized redirect URIs, ajoutez :
  5. Cliquez sur Create, puis copiez l’Client ID et le Client Secret.
Portées demandées automatiquement : openid, email, profile
Note : Pendant le développement, l’écran de consentement affichera un avertissement “This app is not verified”. Vous pouvez le dépasser pour les tests. Publiez l’écran de consentement si vous souhaitez supprimer l’avertissement pour les utilisateurs finaux.

Discord

Console de développement : https://discord.com/developers/applications
  1. Cliquez sur New Application et donnez-lui un nom.
  2. Dans la barre latérale gauche, cliquez sur OAuth2.
  3. Sous Redirects, cliquez sur Add Redirect et entrez :
  4. Copiez l’ID Client (affiché en haut de la page OAuth2) et cliquez sur Reset Secret pour révéler le Secret Client.
Portées demandées automatiquement : identify, email
Discord ne garantit pas un email vérifié pour tous les comptes. Si un utilisateur n’a pas vérifié son email auprès de Discord, le champ email peut être null. FIM One crée le compte avec un email null dans ce cas — l’utilisateur peut en ajouter un plus tard dans Paramètres.

Feishu (Lark)

Limité à la portée du locataire. Les applications internes Feishu (自建应用) ne peuvent authentifier que les utilisateurs du même locataire d’entreprise qui a créé l’application. Les utilisateurs d’autres locataires Feishu verront une erreur « pas de permission ». Cela signifie que Feishu OAuth n’est pas adapté aux déploiements SaaS publics où les utilisateurs proviennent d’organisations différentes. Il fonctionne bien pour les déploiements privés / monoorganisation où tous les utilisateurs appartiennent au même locataire Feishu.Pour prendre en charge la connexion Feishu multi-locataires, vous devez publier l’application dans le Répertoire des applications Feishu (应用商店) et passer le processus d’examen de Feishu — ce qui est complexe et a des exigences strictes.
Console de développeur : https://open.feishu.cn/app
  1. Cliquez sur Create App → In-house app (自建应用). Les comptes d’entreprise/organisation sont requis — Feishu OAuth n’est pas disponible pour les comptes personnels.
  2. Sous Permissions & Scopes, recherchez et activez :
    • contact:user.email:readonly
  3. Sous Security Settings → Redirect URL, ajoutez votre URL de rappel :
  4. Copiez l’App ID et l’App Secret de la section Credentials & Basic Info.
Portées configurées dans la console (pas dans l’URL d’autorisation) : contact:user.email:readonly
Note : Feishu utilise App ID / App Secret au lieu de la dénomination standard Client ID / Client Secret. Les noms des variables d’environnement reflètent cela : FEISHU_APP_ID et FEISHU_APP_SECRET.

Important: Feishu Email Behavior

The Feishu user info API (authen/v1/user_info) returns an email and an enterprise contact email (联系邮箱, enterprise_email) — the address configured by the organization admin in the Feishu admin console. FIM One reads email first, then enterprise_email. The address counts as verified only when it is the enterprise email of a tenant listed in FEISHU_TRUSTED_TENANT_KEYS. Consequences:
  • Users whose org admin has not configured a contact email will get an empty email field from the API, even though they have a valid Feishu account.
  • Users on personal Feishu accounts (not part of an enterprise) will always get an empty email.
FIM One handles this gracefully: see Account Binding Rules below.

Règles de liaison de compte

Les utilisateurs enregistrés peuvent lier des fournisseurs OAuth supplémentaires à partir de Paramètres → Compte. Les règles suivantes s’appliquent lorsqu’un utilisateur initie une liaison :

Linking from Settings (all providers)

Linking needs a full sign-in: a session that has passed two-factor authentication where it is enabled. API keys and the temporary 2FA token cannot link a provider.
  • Both sides have an email → the email returned by the provider must match the FIM account’s email. This prevents accidentally linking another person’s social account to your FIM account. A mismatch is rejected with an email_mismatch error.
  • Either side has no email (the provider returned none, or the FIM account has no email) → binding succeeds on the signed-in session alone. In practice this affects Feishu accounts without an enterprise email and some Discord accounts.

First sign-in with a provider (no binding yet)

When a user signs in through a provider that is not linked to any account yet:
  1. FIM One looks for an existing account with the same email. The match is used only when the address is verified on both sides: the provider reports it as verified, and the existing account’s email is verified. For Feishu, “verified” means the enterprise email of a tenant listed in FEISHU_TRUSTED_TENANT_KEYS.
  2. If a match is found, the provider is linked to that existing FIM account and the user is logged in.
  3. Otherwise a new FIM account is created with whatever email the provider returned (none, if it returned none). This is refused with registration_disabled when registration is disabled or invite-only.
When is an account’s email verified? When it was registered with the emailed verification code (email_verification_enabled on and SMTP configured), when an administrator created it, when it is the first account of the installation, or when it was created by a provider sign-in whose provider reported the address as verified. An account registered with an email and a password on a deployment that does not send verification codes holds an unverified address: a provider sign-in for that address is not linked to it and creates a separate account instead, so two accounts can then hold the same address. A password signs in to the account it was set on; an emailed sign-in or reset code goes to the account whose address is verified. To use one account with both, sign in with the password first and link the provider under Settings → Account, instead of using the provider’s button on the sign-in page. If the matched or linked account has two-factor authentication enabled, the sign-in stops at the 2FA step before a session is issued.

Environment Variables Quick Reference

“Required: Both” means both the _ID and _SECRET (or _APP_ID and _APP_SECRET for Feishu) must be set together; setting only one has no effect.
See Environment Variables for full documentation of FRONTEND_URL, API_BASE_URL, and NEXT_PUBLIC_API_URL.