Skip to content

Conversation

@elena-shostak
Copy link
Contributor

@elena-shostak elena-shostak commented Mar 21, 2025

Summary

Currently, our requiredPrivileges structure supports allRequired and anyRequired for defining authorization logic. However, there is a need to support more complex scenarios as (privilege1 AND privilege2) OR (privilege3 AND privilege4)

To achieve anyRequired has been extended to allow defining multiple AND conditions evaluated with OR logic:

security: {
  authz: {
    requiredPrivileges: [{
       anyRequired: [
          { allOf: ['privilege1', 'privilege2'] }, 
          { allOf: ['privilege3', 'privilege4'] }
        ] 
      }
    ]
  }
}

allRequired now also supports scenarios (privilege1 OR privilege2) AND (privilege3 OR privilege4)

security: {
  authz: {
    requiredPrivileges: [{
       allRequired: [
          { anyOf: ['privilege1', 'privilege2'] }, 
          { anyOf: ['privilege3', 'privilege4'] }
        ] 
      }
    ]
  }
}

Important

We expect to have unique privileges in anyOf or allOf conditions, assuming that most complex conditions can be simplified by boolean algebra laws (OR/AND distributive etc).

Checklist

  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Closes: #210977

@elena-shostak elena-shostak force-pushed the 210977-nested-privilege-conditions branch from 0675342 to 418e0a8 Compare March 25, 2025 12:19
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/dashboards --update'
@elena-shostak elena-shostak added Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// Feature:Security/Authorization Platform Security - Authorization enhancement New value added to drive a business result release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor backport:version Backport to applied version labels 8.19 candidate v8.19.0 and removed 8.19 candidate labels Mar 25, 2025
@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak elena-shostak marked this pull request as ready for review March 26, 2025 09:40
@elena-shostak elena-shostak requested review from a team as code owners March 26, 2025 09:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

privilegeEntry.allRequired.some((entry) =>
typeof entry === 'string'
? isApiPrivilegeSecurityAndDisabled(entry)
: entry.anyOf.every(isApiPrivilegeSecurityAndDisabled)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

I inverted the conditions for anyOf and allOf respectively taking into consideration how allRequired and anyRequired were handled. Would like the team to validate it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Elena, It looks good to me 💯
Would it be possible to add this scenario to the test? So we'll have empirical validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 76b7c46

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 👍

privilegeEntry.anyRequired.every((entry) =>
typeof entry === 'string'
? isApiPrivilegeSecurityAndDisabled(entry)
: entry.allOf.some(isApiPrivilegeSecurityAndDisabled)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Same as above

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, did not review the security plugin code too in-depth. Left a q about exporting the unwind utility, not a blocker though. Nice work!

Copy link
Contributor

@SiddharthMantri SiddharthMantri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool! LGTM!

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@semd semd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-http-server 244 246 +2
@kbn/core-security-server 63 65 +2
total +4

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/core 866 868 +2
Unknown metric groups

API count

id before after diff
@kbn/core-http-server 572 574 +2
@kbn/core-security-server 147 149 +2
total +4

History

@elena-shostak elena-shostak merged commit ed05808 into elastic:main Apr 3, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/14242961679

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts
9.0 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.0:
- [Saved objects] Update import docs (#216658)
- [Docs] Reproduce #209403 in new API docs (#216439)

Manual backport

To create the backport manually run:

node scripts/backport --pr 215516

Questions ?

Please refer to the Backport tool documentation

@elena-shostak
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

elena-shostak added a commit to elena-shostak/kibana that referenced this pull request Apr 3, 2025
## Summary

Currently, our `requiredPrivileges` structure supports `allRequired` and
`anyRequired` for defining authorization logic. However, there is [a
need to
support](elastic#205335 (comment))
more complex scenarios as `(privilege1 AND privilege2) OR (privilege3
AND privilege4)`

To achieve `anyRequired` has been extended to allow defining multiple
AND conditions evaluated with OR logic:
```ts
security: {
  authz: {
    requiredPrivileges: [{
       anyRequired: [
          { allOf: ['privilege1', 'privilege2'] },
          { allOf: ['privilege3', 'privilege4'] }
        ]
      }
    ]
  }
}
```

`allRequired` now also supports scenarios `(privilege1 OR privilege2)
AND (privilege3 OR privilege4)`
```ts
security: {
  authz: {
    requiredPrivileges: [{
       allRequired: [
          { anyOf: ['privilege1', 'privilege2'] },
          { anyOf: ['privilege3', 'privilege4'] }
        ]
      }
    ]
  }
}
```

> [!IMPORTANT]
> We expect to have unique privileges in `anyOf` or `allOf` conditions,
assuming that most complex conditions can be simplified by boolean
algebra laws (OR/AND distributive etc).

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

__Closes: https://github.com/elastic/kibana/issues/210977__

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit ed05808)

# Conflicts:
#	oas_docs/bundle.json
#	oas_docs/bundle.serverless.json
#	oas_docs/output/kibana.serverless.yaml
#	oas_docs/output/kibana.yaml
#	src/core/packages/http/router-server-internal/tsconfig.json
#	src/platform/packages/shared/kbn-router-to-openapispec/src/__snapshots__/generate_oas.test.ts.snap
#	src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.test.fixture.ts
@elena-shostak
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

elena-shostak added a commit to elena-shostak/kibana that referenced this pull request Apr 3, 2025
## Summary

Currently, our `requiredPrivileges` structure supports `allRequired` and
`anyRequired` for defining authorization logic. However, there is [a
need to
support](elastic#205335 (comment))
more complex scenarios as `(privilege1 AND privilege2) OR (privilege3
AND privilege4)`

To achieve `anyRequired` has been extended to allow defining multiple
AND conditions evaluated with OR logic:
```ts
security: {
  authz: {
    requiredPrivileges: [{
       anyRequired: [
          { allOf: ['privilege1', 'privilege2'] },
          { allOf: ['privilege3', 'privilege4'] }
        ]
      }
    ]
  }
}
```

`allRequired` now also supports scenarios `(privilege1 OR privilege2)
AND (privilege3 OR privilege4)`
```ts
security: {
  authz: {
    requiredPrivileges: [{
       allRequired: [
          { anyOf: ['privilege1', 'privilege2'] },
          { anyOf: ['privilege3', 'privilege4'] }
        ]
      }
    ]
  }
}
```

> [!IMPORTANT]
> We expect to have unique privileges in `anyOf` or `allOf` conditions,
assuming that most complex conditions can be simplified by boolean
algebra laws (OR/AND distributive etc).

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

__Closes: https://github.com/elastic/kibana/issues/210977__

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit ed05808)

# Conflicts:
#	oas_docs/bundle.json
#	oas_docs/bundle.serverless.json
#	oas_docs/output/kibana.serverless.yaml
#	oas_docs/output/kibana.yaml
#	src/platform/packages/shared/kbn-router-to-openapispec/src/__snapshots__/generate_oas.test.ts.snap
#	src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.test.fixture.ts
elena-shostak added a commit that referenced this pull request Apr 4, 2025
)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Authz] Added allOf and anyOf nested conditions
(#215516)](#215516)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Elena
Shostak","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-03T12:28:17Z","message":"[Authz]
Added allOf and anyOf nested conditions (#215516)\n\n##
Summary\n\nCurrently, our `requiredPrivileges` structure supports
`allRequired` and\n`anyRequired` for defining authorization logic.
However, there is [a\nneed
to\nsupport](https://github.com/elastic/kibana/pull/205335#issuecomment-2569275302)\nmore
complex scenarios as `(privilege1 AND privilege2) OR (privilege3\nAND
privilege4)`\n\nTo achieve `anyRequired` has been extended to allow
defining multiple\nAND conditions evaluated with OR
logic:\n```ts\nsecurity: {\n authz: {\n requiredPrivileges: [{\n
anyRequired: [\n { allOf: ['privilege1', 'privilege2'] }, \n { allOf:
['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n`allRequired`
now also supports scenarios `(privilege1 OR privilege2)\nAND (privilege3
OR privilege4)`\n```ts\nsecurity: {\n authz: {\n requiredPrivileges:
[{\n allRequired: [\n { anyOf: ['privilege1', 'privilege2'] }, \n {
anyOf: ['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n>
[!IMPORTANT]\n> We expect to have unique privileges in `anyOf` or
`allOf` conditions,\nassuming that most complex conditions can be
simplified by boolean\nalgebra laws (OR/AND distributive etc).\n\n\n###
Checklist\n\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n__Closes:
https://github.com/elastic/kibana/issues/210977__\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"ed058086e27c2b6f5015647b446304608d6b14a9","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","enhancement","release_note:skip","Feature:Security/Authorization","backport:prev-minor","backport:version","v9.1.0","v8.19.0"],"title":"[Authz]
Added allOf and anyOf nested
conditions","number":215516,"url":"https://github.com/elastic/kibana/pull/215516","mergeCommit":{"message":"[Authz]
Added allOf and anyOf nested conditions (#215516)\n\n##
Summary\n\nCurrently, our `requiredPrivileges` structure supports
`allRequired` and\n`anyRequired` for defining authorization logic.
However, there is [a\nneed
to\nsupport](https://github.com/elastic/kibana/pull/205335#issuecomment-2569275302)\nmore
complex scenarios as `(privilege1 AND privilege2) OR (privilege3\nAND
privilege4)`\n\nTo achieve `anyRequired` has been extended to allow
defining multiple\nAND conditions evaluated with OR
logic:\n```ts\nsecurity: {\n authz: {\n requiredPrivileges: [{\n
anyRequired: [\n { allOf: ['privilege1', 'privilege2'] }, \n { allOf:
['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n`allRequired`
now also supports scenarios `(privilege1 OR privilege2)\nAND (privilege3
OR privilege4)`\n```ts\nsecurity: {\n authz: {\n requiredPrivileges:
[{\n allRequired: [\n { anyOf: ['privilege1', 'privilege2'] }, \n {
anyOf: ['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n>
[!IMPORTANT]\n> We expect to have unique privileges in `anyOf` or
`allOf` conditions,\nassuming that most complex conditions can be
simplified by boolean\nalgebra laws (OR/AND distributive etc).\n\n\n###
Checklist\n\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n__Closes:
https://github.com/elastic/kibana/issues/210977__\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"ed058086e27c2b6f5015647b446304608d6b14a9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215516","number":215516,"mergeCommit":{"message":"[Authz]
Added allOf and anyOf nested conditions (#215516)\n\n##
Summary\n\nCurrently, our `requiredPrivileges` structure supports
`allRequired` and\n`anyRequired` for defining authorization logic.
However, there is [a\nneed
to\nsupport](https://github.com/elastic/kibana/pull/205335#issuecomment-2569275302)\nmore
complex scenarios as `(privilege1 AND privilege2) OR (privilege3\nAND
privilege4)`\n\nTo achieve `anyRequired` has been extended to allow
defining multiple\nAND conditions evaluated with OR
logic:\n```ts\nsecurity: {\n authz: {\n requiredPrivileges: [{\n
anyRequired: [\n { allOf: ['privilege1', 'privilege2'] }, \n { allOf:
['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n`allRequired`
now also supports scenarios `(privilege1 OR privilege2)\nAND (privilege3
OR privilege4)`\n```ts\nsecurity: {\n authz: {\n requiredPrivileges:
[{\n allRequired: [\n { anyOf: ['privilege1', 'privilege2'] }, \n {
anyOf: ['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n>
[!IMPORTANT]\n> We expect to have unique privileges in `anyOf` or
`allOf` conditions,\nassuming that most complex conditions can be
simplified by boolean\nalgebra laws (OR/AND distributive etc).\n\n\n###
Checklist\n\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n__Closes:
https://github.com/elastic/kibana/issues/210977__\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"ed058086e27c2b6f5015647b446304608d6b14a9"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/217050","number":217050,"state":"OPEN"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
elena-shostak added a commit that referenced this pull request Apr 4, 2025
)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Authz] Added allOf and anyOf nested conditions
(#215516)](#215516)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Elena
Shostak","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-03T12:28:17Z","message":"[Authz]
Added allOf and anyOf nested conditions (#215516)\n\n##
Summary\n\nCurrently, our `requiredPrivileges` structure supports
`allRequired` and\n`anyRequired` for defining authorization logic.
However, there is [a\nneed
to\nsupport](https://github.com/elastic/kibana/pull/205335#issuecomment-2569275302)\nmore
complex scenarios as `(privilege1 AND privilege2) OR (privilege3\nAND
privilege4)`\n\nTo achieve `anyRequired` has been extended to allow
defining multiple\nAND conditions evaluated with OR
logic:\n```ts\nsecurity: {\n authz: {\n requiredPrivileges: [{\n
anyRequired: [\n { allOf: ['privilege1', 'privilege2'] }, \n { allOf:
['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n`allRequired`
now also supports scenarios `(privilege1 OR privilege2)\nAND (privilege3
OR privilege4)`\n```ts\nsecurity: {\n authz: {\n requiredPrivileges:
[{\n allRequired: [\n { anyOf: ['privilege1', 'privilege2'] }, \n {
anyOf: ['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n>
[!IMPORTANT]\n> We expect to have unique privileges in `anyOf` or
`allOf` conditions,\nassuming that most complex conditions can be
simplified by boolean\nalgebra laws (OR/AND distributive etc).\n\n\n###
Checklist\n\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n__Closes:
https://github.com/elastic/kibana/issues/210977__\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"ed058086e27c2b6f5015647b446304608d6b14a9","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","enhancement","release_note:skip","Feature:Security/Authorization","backport:prev-minor","backport:version","v9.1.0","v8.19.0"],"title":"[Authz]
Added allOf and anyOf nested
conditions","number":215516,"url":"https://github.com/elastic/kibana/pull/215516","mergeCommit":{"message":"[Authz]
Added allOf and anyOf nested conditions (#215516)\n\n##
Summary\n\nCurrently, our `requiredPrivileges` structure supports
`allRequired` and\n`anyRequired` for defining authorization logic.
However, there is [a\nneed
to\nsupport](https://github.com/elastic/kibana/pull/205335#issuecomment-2569275302)\nmore
complex scenarios as `(privilege1 AND privilege2) OR (privilege3\nAND
privilege4)`\n\nTo achieve `anyRequired` has been extended to allow
defining multiple\nAND conditions evaluated with OR
logic:\n```ts\nsecurity: {\n authz: {\n requiredPrivileges: [{\n
anyRequired: [\n { allOf: ['privilege1', 'privilege2'] }, \n { allOf:
['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n`allRequired`
now also supports scenarios `(privilege1 OR privilege2)\nAND (privilege3
OR privilege4)`\n```ts\nsecurity: {\n authz: {\n requiredPrivileges:
[{\n allRequired: [\n { anyOf: ['privilege1', 'privilege2'] }, \n {
anyOf: ['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n>
[!IMPORTANT]\n> We expect to have unique privileges in `anyOf` or
`allOf` conditions,\nassuming that most complex conditions can be
simplified by boolean\nalgebra laws (OR/AND distributive etc).\n\n\n###
Checklist\n\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n__Closes:
https://github.com/elastic/kibana/issues/210977__\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"ed058086e27c2b6f5015647b446304608d6b14a9"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215516","number":215516,"mergeCommit":{"message":"[Authz]
Added allOf and anyOf nested conditions (#215516)\n\n##
Summary\n\nCurrently, our `requiredPrivileges` structure supports
`allRequired` and\n`anyRequired` for defining authorization logic.
However, there is [a\nneed
to\nsupport](https://github.com/elastic/kibana/pull/205335#issuecomment-2569275302)\nmore
complex scenarios as `(privilege1 AND privilege2) OR (privilege3\nAND
privilege4)`\n\nTo achieve `anyRequired` has been extended to allow
defining multiple\nAND conditions evaluated with OR
logic:\n```ts\nsecurity: {\n authz: {\n requiredPrivileges: [{\n
anyRequired: [\n { allOf: ['privilege1', 'privilege2'] }, \n { allOf:
['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n`allRequired`
now also supports scenarios `(privilege1 OR privilege2)\nAND (privilege3
OR privilege4)`\n```ts\nsecurity: {\n authz: {\n requiredPrivileges:
[{\n allRequired: [\n { anyOf: ['privilege1', 'privilege2'] }, \n {
anyOf: ['privilege3', 'privilege4'] }\n ] \n }\n ]\n }\n}\n```\n\n>
[!IMPORTANT]\n> We expect to have unique privileges in `anyOf` or
`allOf` conditions,\nassuming that most complex conditions can be
simplified by boolean\nalgebra laws (OR/AND distributive etc).\n\n\n###
Checklist\n\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n__Closes:
https://github.com/elastic/kibana/issues/210977__\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"ed058086e27c2b6f5015647b446304608d6b14a9"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels enhancement New value added to drive a business result Feature:Security/Authorization Platform Security - Authorization release_note:skip Skip the PR/issue when compiling release notes Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Authorization] Extend privileges config to support OR evaluations

7 participants