shwstppr opened a new pull request, #8973:
URL: https://github.com/apache/cloudstack/pull/8973

   ### Description
   
   API params can be marked accessible to selected role types using  
`authorized` values in API command class.
   The existing behaviour of lisApis API was to return all parameters of the 
API irrespective of the caller's role type. This PR fixes it by adding checks 
to filter params.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] build/CI
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):
   
   
   ### How Has This Been Tested?
   
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to 
-->
   
   #### How did you try to break this feature and the system with this change?
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   
   <!-- Please read the 
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) 
document -->
   
   Tested by setting an API param as,
   ```
       @Parameter(name = ApiConstants.SCOPE, type = BaseCmd.CommandType.STRING, 
description = "Scope of the Webhook",
           authorized = {RoleType.Admin, RoleType.DomainAdmin})
       private String scope;
   ```
   
   Using cmk,
   
   ```
   (localcloud) 🐱 > set username admin
   (localcloud) 🐱 > sync
   Discovered 766 APIs
   (localcloud) 🐱 > list apis name=createWebhook filter=name,params
   {
     "api": [
       {
         "name": "createWebhook",
         "params": [
           {
             "description": "an optional domainId for the Webhook. If the 
account parameter is used, domainId must also be used.",
             "length": 255,
             "name": "domainid",
             "related": "listDomainChildren,listDomains",
             "required": false,
             "type": "uuid"
           },
           {
             "description": "Project for the Webhook",
             "length": 255,
             "name": "projectid",
             "related": "activateProject,suspendProject",
             "required": false,
             "type": "uuid"
           },
           {
             "description": "An optional account for the Webhook. Must be used 
with domainId.",
             "length": 255,
             "name": "account",
             "required": false,
             "type": "string"
           },
           {
             "description": "Scope of the Webhook",
             "length": 255,
             "name": "scope",
             "required": false,
             "type": "string"
           },
           {
             "description": "Secret key of the Webhook",
             "length": 255,
             "name": "secretkey",
             "required": false,
             "type": "string"
           },
           {
             "description": "If set to true then SSL verification will be done 
for the Webhook otherwise not",
             "length": 255,
             "name": "sslverification",
             "required": false,
             "type": "boolean"
           },
           {
             "description": "Payload URL of the Webhook",
             "length": 255,
             "name": "payloadurl",
             "required": true,
             "type": "string"
           },
           {
             "description": "State of the Webhook",
             "length": 255,
             "name": "state",
             "required": false,
             "type": "string"
           },
           {
             "description": "Name for the Webhook",
             "length": 255,
             "name": "name",
             "required": true,
             "type": "string"
           },
           {
             "description": "Description for the Webhook",
             "length": 255,
             "name": "description",
             "required": false,
             "type": "string"
           }
         ]
       }
     ],
     "count": 1
   }
   (localcloud) 🐱 > set username user
   (localcloud) 🐱 > sync
   Discovered 340 APIs
   (localcloud) 🐱 > list apis name=createWebhook filter=name,params
   {
     "api": [
       {
         "name": "createWebhook",
         "params": [
           {
             "description": "an optional domainId for the Webhook. If the 
account parameter is used, domainId must also be used.",
             "length": 255,
             "name": "domainid",
             "related": "listDomainChildren,listDomains",
             "required": false,
             "type": "uuid"
           },
           {
             "description": "Project for the Webhook",
             "length": 255,
             "name": "projectid",
             "related": "activateProject,suspendProject",
             "required": false,
             "type": "uuid"
           },
           {
             "description": "An optional account for the Webhook. Must be used 
with domainId.",
             "length": 255,
             "name": "account",
             "required": false,
             "type": "string"
           },
           {
             "description": "Secret key of the Webhook",
             "length": 255,
             "name": "secretkey",
             "required": false,
             "type": "string"
           },
           {
             "description": "If set to true then SSL verification will be done 
for the Webhook otherwise not",
             "length": 255,
             "name": "sslverification",
             "required": false,
             "type": "boolean"
           },
           {
             "description": "Payload URL of the Webhook",
             "length": 255,
             "name": "payloadurl",
             "required": true,
             "type": "string"
           },
           {
             "description": "State of the Webhook",
             "length": 255,
             "name": "state",
             "required": false,
             "type": "string"
           },
           {
             "description": "Name for the Webhook",
             "length": 255,
             "name": "name",
             "required": true,
             "type": "string"
           },
           {
             "description": "Description for the Webhook",
             "length": 255,
             "name": "description",
             "required": false,
             "type": "string"
           }
         ]
       }
     ],
     "count": 1
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to