# Gérer l'appartenance au groupe via l'authentification

**URL:** https://meta.discourse.org/t/managing-group-membership-via-authentication/175950
**Category:** Development
**Created:** [Janvier 13, 2021, 6:50 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950 "2021-01-13T06:50:24Z")
**Posts on this page:** 13
**Page:** 2

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [Novembre 8, 2021, 6:10 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/22 "2021-11-08T06:10:27Z")

</div>

Notez que j’ai fait une version mise à jour de la PR avec une nouvelle approche (intégrant les [changements demandés](https://github.com/discourse/discourse/pull/12446#issuecomment-873399276) par @david lors de ma dernière tentative). Comme mentionné dans les commentaires de la PR, je cherche à la terminer cette semaine.

> <https://github.com/discourse/discourse/pull/14835>
>
> Update on #12446.
> 
> @davidtaylorhq A draft for an update on the associated grou…p membership work. It's been rebased, brought in line with the latest changes and updated in the ways explained below. Let me know if you're onboard with the approach so far. I'll finish it off next weekend.
> 
> \### Authentication and group retrieval
> 
> I've removed the secondary auth stuff, added a google-hd-specific boolean setting, and moved the group retrieval into a new google oauth2 omniauth strategy. I've made a new folder and added a spec for the strategy (something new in the codebase) as I thought it deserved a spec (which is also included). If we add in secondary auth to this strategy that too will need a spec. Some of the existing discourse omniauth strategies, e.g. Discord, may benefit from being seperated out and tested too.
> 
> \### Group Provision and UI
> 
> As suggested, I've added a \`\`provides\_groups?\`\` to the \`\`Auth::Authenticator\`\`. Using this approach led to a new groups guardian method to use at the various group CRUD points. Speaking of which, I've added in support for group\_associated\_group creation in group creation (i.e. \`\`/g/custom/new\`\`). Supporting it in both \`\`new\`\` and \`\`manage\`\` (update) also led to adding a new site attribute \`\`can\_associate\_groups\`\`. I attempted to make this more group-route specific, however this leads to various clumsy workarounds to determine whether an admin can associate groups in \`\`/g/custom/new\`\`. The site attribute approach proved the simplest and most performant (i.e. fewer ajax calls).
> 
> \### Data model
> 
> I've made one change to the data model so far, namely to use \`\`after\_commit\`\` hooks rather than \`\`after\_create\`\`/\`\`after\_destroy\`\` as using those hooks leads to duplicate record creation in \`\`Admin::GroupsController\`\` \`\`create\`\`. I've yet to deal with the edge case you pointed out, i.e. multiple UserAssociatedGroups which link to the same group.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [Novembre 8, 2021, 2:57 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/23 "2021-11-08T14:57:22Z")

</div>

Juste pour ne pas m’emballer pour rien — ceci dit «&nbsp;google&nbsp;»… fonctionnera-t-il aussi avec un SSO OAuth2 non-Google&nbsp;?

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [Novembre 8, 2021, 3:01 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/24 "2021-11-08T15:01:15Z")

</div>

C’est un système générique, mais le premier cas d’utilisation pris en charge sera les groupes dans un Google Workspace. Une fois le système en place, l’ajout de la prise en charge de fournisseurs supplémentaires ne sera pas trop difficile.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [Novembre 22, 2021, 6:06 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/25 "2021-11-22T06:06:29Z")

</div>

Notez que cette PR a été déplacée de brouillon à publiée au cours du week-end (c’est-à-dire qu’elle est prête à être examinée à nouveau).

> <https://github.com/discourse/discourse/pull/14835>
>
> Update on #12446.
> 
> @davidtaylorhq A draft for an update on the associated grou…p membership work. It's been rebased, brought in line with the latest changes and updated in the ways explained below. Let me know if you're onboard with the approach so far. I'll finish it off next weekend.
> 
> \### Authentication and group retrieval
> 
> I've removed the secondary auth stuff, added a google-hd-specific boolean setting, and moved the group retrieval into a new google oauth2 omniauth strategy. I've made a new folder and added a spec for the strategy (something new in the codebase) as I thought it deserved a spec (which is also included). If we add in secondary auth to this strategy that too will need a spec. Some of the existing discourse omniauth strategies, e.g. Discord, may benefit from being seperated out and tested too.
> 
> \### Group Provision and UI
> 
> As suggested, I've added a \`\`provides\_groups?\`\` to the \`\`Auth::Authenticator\`\`. Using this approach led to a new groups guardian method to use at the various group CRUD points. Speaking of which, I've added in support for group\_associated\_group creation in group creation (i.e. \`\`/g/custom/new\`\`). Supporting it in both \`\`new\`\` and \`\`manage\`\` (update) also led to adding a new site attribute \`\`can\_associate\_groups\`\`. I attempted to make this more group-route specific, however this leads to various clumsy workarounds to determine whether an admin can associate groups in \`\`/g/custom/new\`\`. The site attribute approach proved the simplest and most performant (i.e. fewer ajax calls).
> 
> \### Data model
> 
> I've made one change to the data model so far, namely to use \`\`after\_commit\`\` hooks rather than \`\`after\_create\`\`/\`\`after\_destroy\`\` as using those hooks leads to duplicate record creation in \`\`Admin::GroupsController\`\` \`\`create\`\`. I've yet to deal with the edge case you pointed out, i.e. multiple UserAssociatedGroups which link to the same group.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [Décembre 9, 2021, 12:32 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/26 "2021-12-09T12:32:39Z")

</div>

J’ai fusionné cette PR - un grand merci pour tout votre travail ici @angus ! J’ai hâte de voir comment cela sera utilisé et étendu à l’avenir ! 🎊

J’ai marqué le paramètre du site comme « Expérimental » pour l’instant, afin de nous laisser le temps de le tester et de nous assurer que tout fonctionne correctement. Une fois que nous serons convaincus et que nous aurons ajouté la prise en charge de quelques fournisseurs d’authentification supplémentaires, je ne manquerai pas de créer un sujet #feature:announcements pour cette fonctionnalité.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [Décembre 9, 2021, 1:44 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/27 "2021-12-09T13:44:15Z")

</div>

Génial ! :)\n\nMerci _à toi_ David. Cela n’aurait pas été possible sans ton soutien. Heureux d’aider à l’ajout de fournisseurs supplémentaires.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [Décembre 9, 2021, 2:18 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/28 "2021-12-09T14:18:05Z")

</div>

> [@david](#):
>
> Je viens de fusionner cette PR - un immense merci pour tout votre travail ici @angus ! J’ai hâte de voir comment cela sera utilisé et étendu à l’avenir ! 🎊

OUI ! Merci à tous. Nous prévoyons d’utiliser cela intensivement dans Fedora une fois qu’il fonctionnera avec oauth2.

---

<div class="post-metadata">

### Author: ![jimkleiber](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimkleiber/32/121814_2.png) [@jimkleiber](https://meta.discourse.org/u/jimkleiber)
#### Post date: [Mars 10, 2022, 11:57 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/29 "2022-03-10T23:57:43Z")

</div>

Je suis également ravi que cela soit disponible pour les connexions autres que Google OAuth2/OpenID… y a-t-il des nouvelles sur la disponibilité de cette option ?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [Mars 11, 2022, 11:49 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/30 "2022-03-11T11:49:07Z")

</div>

Nous n’avons pas de calendrier précis, mais c’est certainement #pr-welcome si quelqu’un souhaite soumettre un correctif

---

<div class="post-metadata">

### Author: ![agungor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agungor/32/260344_2.png) [@agungor](https://meta.discourse.org/u/agungor)
#### Post date: [Mai 19, 2022, 3:11 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/31 "2022-05-19T15:11:12Z")

</div>

> [@jimkleiber](#):
>
> Je suis également impatient que cela soit disponible pour les connexions non-Google oauth2/openID… y a-t-il des nouvelles sur si/quand cette option pourrait être disponible&nbsp;?

J’attends cela avec impatience également&nbsp;! Le cas d’utilisation pour nous est de récupérer l’appartenance aux groupes de Keycloak lors de l’authentification.

---

<div class="post-metadata">

### Author: ![irregular](https://avatars.discourse-cdn.com/v4/letter/i/f9ae1b/32.png) [@irregular](https://meta.discourse.org/u/irregular)
#### Post date: [Août 11, 2024, 10:25 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/32 "2024-08-11T22:25:52Z")

</div>

J’héberge actuellement Discourse moi-même et j’utilise Authentik comme fournisseur d’identité pour l’authentification. Ce que j’aimerais réaliser, c’est synchroniser automatiquement les groupes d’utilisateurs d’Authentik avec des groupes spécifiques dans Discourse lors de la connexion.

Mais… je veux m’assurer que les utilisateurs locaux qui s’inscrivent via le processus d’inscription local de Discourse ne soient pas assignés à ces groupes spécifiques et suivent plutôt la progression normale du niveau de confiance.

---

<div class="post-metadata">

### Author: ![bsoares](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bsoares/32/231482_2.png) [@bsoares](https://meta.discourse.org/u/bsoares)
#### Post date: [Septembre 10, 2025, 4:42 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/33 "2025-09-10T16:42:45Z")

</div>

Salut !

Nous avons migré notre authentification d’Atlassian Crowd (qui n’est plus pris en charge dans Discourse) vers OpenID Connect (via Keycloak) et souhaitions utiliser le code de mappage de groupes Crowd que nous avons contribué il y a quelques années dans le plugin discourse-openid-connect.

Nous avons des modifications de code fonctionnelles qui permettent de configurer des mappages entre les groupes OpenID Connect et les groupes Discourse, et nous les avons soumises dans une PR [FEATURE: Openid connect group maps by benzoid · Pull Request #34763 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/34763).

Nous espérons que cela pourra être pris en compte pour être fusionné et serions disposés à ajouter de la documentation ou des tests (si l’on peut m’indiquer un guide pour les tests – je ne suis pas un programmeur ruby natif (pas encore) !).

Ben

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [Avril 29, 2026, 11:00 UTC](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950/34 "2026-04-29T11:00:52Z")

</div>

Pour la forme : la synchronisation des groupes est désormais disponible pour OIDC. Pour plus d’informations, consultez le sujet du plugin et [le journal des modifications récent](https://releases.discourse.org/changelog/v2026.4.0).

> [@Discourse](#):
>
> ### Synchronisation des groupes
> 
> Le plugin peut automatiquement synchroniser les appartenances aux groupes de votre fournisseur OpenID Connect vers les groupes Discourse. À chaque connexion, le plugin lira la revendication configurée dans le jeton OIDC et mettra à jour les appartenances aux groupes de l’utilisateur en conséquence. Pour activer la synchronisation des groupes :
> 
> 1. Configurez votre fournisseur d’identité pour qu’il renvoie un tableau de groupes dans l’une des revendications. Cela doit être un tableau de chaînes de caractères.
> 2. Définissez **`openid_connect_groups_claim`** sur le nom de la revendication dans le jeton OIDC qui contient les groupes de l’utilisateur (par exemple `cognito:groups`). Une fois défini, cela commencera à synchroniser les informations vers le système « Groupes associés » de Discourse.
> 3. Trouvez le groupe Discourse que vous souhaitez lier. Allez dans « Paramètres » → « Adhésion » → « Automatique », puis choisissez les Groupes associés à lier. Cette liste déroulante est remplie par des informations provenant du fournisseur d’identité, donc au moins un membre du groupe doit s’être connecté pour qu’une option apparaisse.
> 
> ![image](https://global.discourse-cdn.com/meta/original/4X/8/5/6/8563d51d15b37f23bd600cf4e735b7a3b09ed7e7.png)

[Page précédente](https://meta.discourse.org/t/managing-group-membership-via-authentication/175950.md?page=1)
