File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,18 @@ Available features:
1616 occ app:enable admin_group_manager
1717 occ app:enable groupquota
1818 ```
19+ - Allowed IP
20+
21+ By security, this API only receive requests from a specific IP.
22+ - Run a tail with grep to watch by the word "Unauthorized access".
23+ ```bash
24+ tail -f data/nextcloud.log|grep "Unauthorized access"
25+ ```
26+ - Do a request to API endpoint and go back to terminal to check the logs and get the IP.
27+ - With the IP, run the follow command:
28+ ```bash
29+ occ config:system:set admin_group_manager_allowed_ip --value <theIdentifiedIp>
30+ ```
1931
2032## Performance improving
2133Systemd service
Original file line number Diff line number Diff line change 1616use OCP \AppFramework \OCS \OCSException ;
1717use OCP \IConfig ;
1818use OCP \IRequest ;
19+ use Psr \Log \LoggerInterface ;
1920
2021class InjectionMiddleware extends Middleware {
2122
2223 public function __construct (
2324 private IRequest $ request ,
2425 private IConfig $ config ,
26+ private LoggerInterface $ logger ,
2527 ) {
2628 $ this ->request = $ request ;
2729 }
@@ -49,6 +51,7 @@ private function restrictIp(): void {
4951 $ ip = $ this ->request ->getRemoteAddress ();
5052 $ allowed = $ this ->config ->getSystemValue ('admin_group_manager_allowed_ip ' );
5153 if ($ allowed !== $ ip ) {
54+ $ this ->logger ->error ('Unauthorized access to API ' , ['IP ' => $ ip ]);
5255 throw new OCSException ('' , Http::STATUS_UNAUTHORIZED );
5356 }
5457 }
You can’t perform that action at this time.
0 commit comments