Fix re-enabling OAuth2 security on APIs configured with only mutual SSL #12742
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This PR resolves an issue where an API published with only Mutual SSL enabled cannot save updates when OAuth2 or API Key application-level security is subsequently enabled.
Approach
When Mutual SSL is the sole selected security option for an API, the tier throttling policies are cleared [1]. If OAuth2 or API Key is later enabled for the same API, the update fails because the API is already published and requires a tier throttling policy. This fix ensures that a default throttling policy is applied in such scenarios, allowing the updates to be successfully saved.
Logic to filter AI policies is based on [2].
Issue
Related to: wso2/api-manager#3486
[1]
carbon-apimgt/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java
Lines 315 to 320 in bf7e34d
[2]
carbon-apimgt/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ThrottlingPoliciesApiServiceImpl.java
Lines 206 to 209 in bf7e34d