Fix GitHub app auth and migrations
This commit is contained in:
parent
9418ba8775
commit
7c184498bb
3 changed files with 8 additions and 17 deletions
|
@ -277,6 +277,11 @@ App::get('/v1/vcs/github/callback')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('dbForConsole')
|
->inject('dbForConsole')
|
||||||
->action(function (string $providerInstallationId, string $setupAction, string $state, string $code, GitHub $github, Document $user, Document $project, Request $request, Response $response, Database $dbForConsole) {
|
->action(function (string $providerInstallationId, string $setupAction, string $state, string $code, GitHub $github, Document $user, Document $project, Request $request, Response $response, Database $dbForConsole) {
|
||||||
|
if (empty($state)) {
|
||||||
|
$error = 'Installation requests from organisation members for the Appwrite GitHub App are currently unsupported. To proceed with the installation, login to the Appwrite Console and install the GitHub App.';
|
||||||
|
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $error);
|
||||||
|
}
|
||||||
|
|
||||||
$state = \json_decode($state, true);
|
$state = \json_decode($state, true);
|
||||||
$projectId = $state['projectId'] ?? '';
|
$projectId = $state['projectId'] ?? '';
|
||||||
|
|
||||||
|
@ -285,25 +290,11 @@ App::get('/v1/vcs/github/callback')
|
||||||
'failure' => $request->getProtocol() . '://' . $request->getHostname() . "/console/project-$projectId/settings/git-installations",
|
'failure' => $request->getProtocol() . '://' . $request->getHostname() . "/console/project-$projectId/settings/git-installations",
|
||||||
];
|
];
|
||||||
|
|
||||||
$state = \array_merge($defaultState, $state);
|
$state = \array_merge($defaultState, $state ?? []);
|
||||||
|
|
||||||
$redirectSuccess = $state['success'] ?? '';
|
$redirectSuccess = $state['success'] ?? '';
|
||||||
$redirectFailure = $state['failure'] ?? '';
|
$redirectFailure = $state['failure'] ?? '';
|
||||||
|
|
||||||
if (empty($state)) {
|
|
||||||
$error = 'Installation requests from organisation members for the Appwrite GitHub App are currently unsupported. To proceed with the installation, login to the Appwrite Console and install the GitHub App.';
|
|
||||||
|
|
||||||
if (!empty($redirectFailure)) {
|
|
||||||
$separator = \str_contains($redirectFailure, '?') ? '&' : ':';
|
|
||||||
return $response
|
|
||||||
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
|
|
||||||
->addHeader('Pragma', 'no-cache')
|
|
||||||
->redirect($redirectFailure . $separator . \http_build_query(['error' => $error]));
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $error);
|
|
||||||
}
|
|
||||||
|
|
||||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||||
|
|
||||||
if ($project->isEmpty()) {
|
if ($project->isEmpty()) {
|
||||||
|
|
|
@ -319,7 +319,7 @@ App::init()
|
||||||
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
|
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
|
||||||
*/
|
*/
|
||||||
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
||||||
if ($request->getProtocol() !== 'https' && ($swooleRequest->header['host'] ?? '') !== 'localhost') { // Localhost allowed for proxy
|
if ($request->getProtocol() !== 'https' && ($swooleRequest->header['host'] ?? '') !== 'localhost' && ($swooleRequest->header['host'] ?? '') !== APP_HOSTNAME_INTERNAL) { // Localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations
|
||||||
if ($request->getMethod() !== Request::METHOD_GET) {
|
if ($request->getMethod() !== Request::METHOD_GET) {
|
||||||
throw new AppwriteException(AppwriteException::GENERAL_PROTOCOL_UNSUPPORTED, 'Method unsupported over HTTP.');
|
throw new AppwriteException(AppwriteException::GENERAL_PROTOCOL_UNSUPPORTED, 'Method unsupported over HTTP.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -772,7 +772,7 @@ services:
|
||||||
hostname: executor
|
hostname: executor
|
||||||
<<: *x-logging
|
<<: *x-logging
|
||||||
stop_signal: SIGINT
|
stop_signal: SIGINT
|
||||||
image: openruntimes/executor:0.3.2
|
image: openruntimes/executor:0.3.3
|
||||||
networks:
|
networks:
|
||||||
- appwrite
|
- appwrite
|
||||||
- runtimes
|
- runtimes
|
||||||
|
|
Loading…
Reference in a new issue