Skip to content

Commit a5a2efd

Browse files
author
Robert He
committed
MAGETWO-66882: Allowing Web API listing to be public - 2.2
- make all services only available for SOAP while REST is protected
1 parent 4370cfd commit a5a2efd

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function __construct(
7575
}
7676

7777
/**
78-
* Retrieve a list of services visible to current user.
78+
* Retrieve a list of all services.
7979
*
8080
* @return string[]
8181
*/

app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,4 +897,23 @@ private function generateMethodExceptionErrorResponses($exceptionClass, $respons
897897

898898
return $responses;
899899
}
900+
901+
/**
902+
* Retrieve a list of services visible to current user.
903+
*
904+
* @return string[]
905+
*/
906+
public function getListOfServices()
907+
{
908+
$listOfAllowedServices = [];
909+
foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
910+
foreach ($service[$this->serviceMetadata::KEY_SERVICE_METHODS] as $method) {
911+
if ($this->authorization->isAllowed($method[$this->serviceMetadata::KEY_ACL_RESOURCES])) {
912+
$listOfAllowedServices[] = $serviceName;
913+
break;
914+
}
915+
}
916+
}
917+
return $listOfAllowedServices;
918+
}
900919
}

0 commit comments

Comments
 (0)