-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed cyclic imports, talkbots -> Proxy
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
- Loading branch information
Showing
15 changed files
with
86 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\AppAPI\Service; | ||
|
||
use OCA\AppAPI\AppInfo\Application; | ||
use OCP\App\IAppManager; | ||
use OCP\IRequest; | ||
|
||
class AppAPICommonService { | ||
|
||
public function __construct( | ||
private readonly IAppManager $appManager, | ||
) { | ||
} | ||
|
||
public function buildAppAPIAuthHeaders(?IRequest $request, ?string $userId, string $appId, string $appVersion, string $appSecret): array { | ||
return [ | ||
'AA-VERSION' => $this->appManager->getAppVersion(Application::APP_ID, false), | ||
'EX-APP-ID' => $appId, | ||
'EX-APP-VERSION' => $appVersion, | ||
'AUTHORIZATION-APP-API' => base64_encode($userId . ':' . $appSecret), | ||
'AA-REQUEST-ID' => $request instanceof IRequest ? $request->getId() : 'CLI', | ||
]; | ||
} | ||
|
||
public function isAppHostNameLocal(string $hostname): bool { | ||
return $hostname === '127.0.0.1' || $hostname === 'localhost' || $hostname === '::1'; | ||
} | ||
|
||
public function buildExAppHost(array $deployConfig): string { | ||
if (isset($deployConfig['net'])) { | ||
if (($deployConfig['net'] === 'host') && | ||
(isset($deployConfig['host']) && $this->isAppHostNameLocal($deployConfig['host'])) | ||
) { | ||
return '127.0.0.1'; # ExApp using this host network, it is visible for Nextcloud on loop-back adapter | ||
} | ||
return '0.0.0.0'; | ||
} | ||
return '127.0.0.1'; # fallback to loop-back adapter | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters