Skip to content

Conversation

@GaneshPatil7517
Copy link

@GaneshPatil7517 GaneshPatil7517 commented Nov 15, 2025

This PR implements support for AND logic between multiple security schemes in AsyncAPI 3.x, addressing issue #1129.

Problem
Currently, AsyncAPI 3.x only allows expressing OR semantics when multiple security schemes are specified in the security array. This means "any one of these schemes satisfies the requirement." However, there's no way to express that multiple schemes must be satisfied simultaneously (AND logic), which is a common real-world scenario.

For example, you cannot currently express: "Require BOTH OAuth2 AND API Key" or "Require user authentication AND client certificate."

Solution
This PR introduces support for nested array syntax to enable AND logic while maintaining backward compatibility:

Single-level array (existing): OR logic - any one scheme is sufficient
Nested arrays (new): Outer array = OR, Inner array = AND - all schemes in an inner array must be satisfied
Syntax Examples
OR logic (existing - unchanged):
security:

  • oauth2: [ ]
  • apiKey: [ ]

Meaning: OAuth2 AND API Key

AND logic (new):
security:

    • oauth2: [ ]
    • apiKey: [ ]

Combined OR and AND:
security:

    • oauth2: [ ]
    • apiKey: [ ]
  • basicAuth: [ ]

Meaning: (OAuth2 AND API Key) OR Basic Auth

Changes Made
✅ Updated Server Object security field documentation to support array of arrays syntax
✅ Updated Operation Object security field with AND/OR logic support
✅ Updated Operation Trait Object security field with AND/OR logic support
✅ Added comprehensive example: operation-security-and-logic-asyncapi.yml
✅ Added documentation in operation-security-asyncapi.yml explaining OR vs AND logic
✅ Maintains 100% backward compatibility with existing single-level arrays
Backward Compatibility
This change is fully backward compatible. Existing AsyncAPI documents using single-level arrays will continue to work exactly as before with OR semantics. The nested array syntax is purely additive.

Testing
Added two example files demonstrating the feature:

operation-security-and-logic-asyncapi.yml - Shows AND logic usage
Updated operation-security-asyncapi.yml - Documents OR vs AND comparison
Fixes
Fixes #1129
@rahmathm1

)

- Updated Server Object security field to support array of arrays syntax
- Updated Operation Object security field with AND/OR logic support
- Updated Operation Trait Object security field with AND/OR logic support
- Added comprehensive example demonstrating AND logic usage
- Added documentation explaining OR vs AND security logic
- Maintains backward compatibility with existing single-level arrays

Fixes asyncapi#1129
@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Nov 15, 2025

We require all PRs to follow Conventional Commits specification.
More details 👇🏼

 The subject "Add AND logic support for multiple security schemes (#1129)" found in the pull request title "feat: Add AND logic support for multiple security schemes (#1129)" should start with a lowercase character.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarqubecloud
Copy link

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Support AND logic for multiple security schemes in AsyncAPI 3.x

2 participants