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:
16
16
occ app:enable admin_group_manager
17
17
occ app:enable groupquota
18
18
```
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
+ ```
19
31
20
32
## Performance improving
21
33
Systemd service
Original file line number Diff line number Diff line change 16
16
use OCP \AppFramework \OCS \OCSException ;
17
17
use OCP \IConfig ;
18
18
use OCP \IRequest ;
19
+ use Psr \Log \LoggerInterface ;
19
20
20
21
class InjectionMiddleware extends Middleware {
21
22
22
23
public function __construct (
23
24
private IRequest $ request ,
24
25
private IConfig $ config ,
26
+ private LoggerInterface $ logger ,
25
27
) {
26
28
$ this ->request = $ request ;
27
29
}
@@ -49,6 +51,7 @@ private function restrictIp(): void {
49
51
$ ip = $ this ->request ->getRemoteAddress ();
50
52
$ allowed = $ this ->config ->getSystemValue ('admin_group_manager_allowed_ip ' );
51
53
if ($ allowed !== $ ip ) {
54
+ $ this ->logger ->error ('Unauthorized access to API ' , ['IP ' => $ ip ]);
52
55
throw new OCSException ('' , Http::STATUS_UNAUTHORIZED );
53
56
}
54
57
}
You can’t perform that action at this time.
0 commit comments