Skip to content

feat(authz): enforce configurable max entities limit per environment#17325

Open
podlesrafal wants to merge 1 commit into
masterfrom
feat/authz-entity-limit
Open

feat(authz): enforce configurable max entities limit per environment#17325
podlesrafal wants to merge 1 commit into
masterfrom
feat/authz-entity-limit

Conversation

@podlesrafal
Copy link
Copy Markdown
Contributor

Summary

  • Add a configurable cap on the total number of authz entities (principals and resources combined) per environment.
  • Default limit is 1000, configurable via gravitee.authz.entities.max (same @Value pattern as the existing gravitee.authz.cascade-hard-limit / gravitee.authz.sync.max-users).
  • Creating beyond the limit throws AuthzEntityLimitExceededException, mapped to HTTP 409 CONFLICT in AuthzCalls (code EntityLimitExceeded).
  • Enforced for both single upsert and bulk upsert. Replacing an existing entity does not count as a new entity.

Implementation

  • AuthzEntityRepository#count(environmentId) — default impl + Mongo override (kindless count → covers principals + resources).
  • AuthzEntityServiceImplmaxEntities field, enforcement in doUpsert / doBulkUpsert, backward-compatible 6/7/8-arg constructors.
  • SpringConfig — wires gravitee.authz.entities.max into the service bean.

Test plan

  • AuthzEntityServiceImplTest — 35 tests green (incl. 4 new: single/bulk over-limit throws + saves nothing; replace at limit still succeeds; bulk replace does not count against limit).

Add a configurable cap (default 1000, via gravitee.authz.entities.max) on the
total number of authz entities (principals and resources combined) per
environment. Creating beyond the limit throws AuthzEntityLimitExceededException,
mapped to HTTP 409. Replacing existing entities is unaffected.
@podlesrafal podlesrafal requested a review from a team as a code owner June 1, 2026 23:23
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant