# group_membership_managed

The group membership is held only by a directory or email domain mapping (409).

## Meaning

An administrator asked to remove a user from a group
(`DELETE /v1/admin/orgs/{slug}/groups/{id}/members/{user_id}`), and the only source of
the membership is one of the group's mappers: a directory group or an email domain.
Removing it by hand would not last, since the mapper adds the user again at their next
sign-in, so the server refuses and changes nothing. A membership an administrator also
added is not refused: it loses the manual source and stays through the mapper.

## Impact

Nothing changed, and the user keeps the group and the access it gives. This is the
intended answer for a managed membership, not a fault. A mapper re-evaluates the
membership only at a sign-in: a refresh re-checks a client's allowed groups but keeps
the membership, so a user who keeps refreshing keeps the group until they sign in again.

## Diagnosis

1. Look the request id up on the Troubleshooting page. The refusal is recorded as
   `group.member_removed` with reason `conflict`; `mapper_kind` says which kind of
   mapper holds the membership, with `identity_provider` and `group_dn` for a directory
   group and `domain` for an email domain.
2. Read the membership's sources: `GET /v1/admin/orgs/{slug}/users/{id}/groups` shows
   `directory` or `email_domain` on the group.
3. Read the mappings: `GET /v1/admin/orgs/{slug}/groups/{id}` lists
   `directory_mappings` and `email_domains`.

## Mitigation

- To take the access away now: end the user's sessions
  (`DELETE /v1/admin/orgs/{slug}/users/{id}/sessions`), which also retires their
  refresh tokens, so the next token needs a sign-in, and the mapper decides again
  there. Block the user (`POST /v1/admin/orgs/{slug}/users/{id}/block`) when they must
  not sign in again at all.
- For a directory mapping: remove the user from the group in the directory. The
  membership ends at a sign-in whose directory read no longer lists it; a sign-in that
  reads no directory leaves it as it is, so while the directory is unreachable only
  blocking the user or changing the mapping ends it.
- For an email domain mapping: change the user's address. The membership ends at their
  next sign-in with a verified address at no domain the group follows.
- For everyone the mapping covers: change the `Group` resource that declares it.

## Escalation

Escalate when no mapping of the group matches the user and the membership is still
refused. Open an issue with the request id, the organization slug, the group id and the
server version.

---

[Problem code runbooks](https://www.nauthera.io/docs/v1/runbooks/problems) · Generated from [`internal/runbook/problems.yaml`](https://github.com/nauthera/nauthera-server/blob/main/internal/runbook/problems.yaml) in nauthera-server.
