Skip to content

Commit

Permalink
Merge pull request #76 from mertcelen/1.1-dev
Browse files Browse the repository at this point in the history
View Yapısının Değiştirilmesi
  • Loading branch information
mertcelen authored Jul 14, 2020
2 parents 38521aa + 8aadec4 commit 7105d2b
Show file tree
Hide file tree
Showing 178 changed files with 85,237 additions and 8,107 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ EXTENSION_DEVELOPER_MODE=false
QUEUE_DRIVER=database
NAV_EXTENSION_HIDE_COUNT=10
BRAND_NAME="Havelsan © 2020"
MARKET_URL=https://market.mcelen.dev
MARKET_URL=https://market.liman.dev
MARKET_CLIENT_ID=
MARKET_CLIENT_SECRET=
29 changes: 25 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ jobs:
repository: mertcelen/liman-sandbox-python
path: package/liman/sandbox/python
token: ${{ secrets.CI_TOKEN }}

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Getting Liman' WebSSH
uses: actions/checkout@v2
with:
Expand All @@ -41,6 +46,22 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Create Docs
run: |
sudo apt install npm -y
cd package/liman/server/
npm install
npm run docs
echo "api.liman.dev" > storage/docs/CNAME
- name: Push Docs to APIDOCS Repository
uses: cpina/github-action-push-to-another-repository@master
env:
API_TOKEN_GITHUB: ${{ secrets.CI_TOKEN }}
with:
source-directory: 'package/liman/server/storage/docs'
destination-github-username: 'limanmys'
destination-repository-name: 'apidocs'
user-email: mcelen94@gmail.com
- name: Set up Liman Environment
uses: shivammathur/setup-php@v2
with:
Expand All @@ -60,8 +81,8 @@ jobs:
git --git-dir=package/liman/server/.git log -30 --pretty=format:"%s%x09%ad" > package/liman/server/storage/changelog
rm -rf package/liman/server/.git package/liman/sandbox/php/.git package/liman/sandbox/python/.git
rm -rf package/liman/server/node_modules
mv package/liman/server/build_tools/DEBIAN package/
rm -rf package/liman/server/build_tools
mv package/liman/server/storage/build_tools/DEBIAN package/
rm -rf package/liman/server/storage/build_tools
cd package
touch DEBIAN/md5sums
touch DEBIAN/md5sums
Expand All @@ -81,7 +102,7 @@ jobs:
Architecture: amd64
Priority: important
Description: Liman MYS
Depends: zip, unzip, dnsutils, nginx, php7.3-fpm, php7.3-curl, php7.3, php7.3-sqlite3, php7.3-ldap, php7.3-snmp, php7.3-mbstring, php7.3-xml, php7.3-zip, php7.3-ssh2, php7.3-posix, libnginx-mod-http-headers-more-filter, php7.3-smbclient, krb5-user, smbclient, libssl1.1, acl, novnc, supervisor, expect, php-mongodb, php7.3-gd, rsyslog, python3.7, python3-jinja2, python3-requests, python3-crypto, python3-paramiko, python3-tornado
Depends: zip, unzip, dnsutils, nginx, redis, php-redis, php7.3-fpm, php7.3-curl, php7.3, php7.3-sqlite3, php7.3-ldap, php7.3-snmp, php7.3-mbstring, php7.3-xml, php7.3-zip, php7.3-ssh2, php7.3-posix, libnginx-mod-http-headers-more-filter, php7.3-smbclient, krb5-user, smbclient, libssl1.1, acl, novnc, supervisor, expect, php-mongodb, php7.3-gd, rsyslog, python3.7, python3-jinja2, python3-requests, python3-crypto, python3-paramiko, python3-tornado
""" > DEBIAN/control
cd ../
dpkg-deb -Zgzip --build package
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ vendor/*
.env
config/liman.php
storage/extension_updates
storage/docs
public/docs
2 changes: 1 addition & 1 deletion apidoc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Liman MYS",
"version": "1.0",
"version": "1.0.0",
"description": "Liman MYS Api Documentation",
"title": "Liman",
"url" : "https://liman.dev"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Classes\Connector;
namespace App\Connectors;

interface Connector
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Classes\Connector;
namespace App\Connectors;

use App\Models\UserSettings;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Classes\Connector;
namespace App\Connectors;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Classes\Connector;
namespace App\Connectors;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace App\Classes\Connector;
namespace App\Connectors;

use App\Models\TunnelToken;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;

/**
* Class SSHTunnelConnector
* @package App\Classes\Connector
* @package App\Connectors
*/
class SSHTunnelConnector
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Classes\Connector;
namespace App\Connectors;

use App\Models\Server;
use App\Models\UserSettings;
Expand Down
94 changes: 50 additions & 44 deletions app/Http/Controllers/Certificate/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@

class MainController extends Controller
{
/**
* @api {post} /sunucu/sertifikaOnayi Add SSL Sertificate
* @apiName Add SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} server_hostname Server's hostname.
* @apiParam {String} origin Target port to retrieve certificate.
* @apiParam {String} notification_id Request Notification Id (OPTIONAL)
*
* @apiSuccess {JSON} message Message with status.
*/
public function verifyCert()
{
// Check If Certificate Already Added or not.
if (
Certificate::where([
"server_hostname" => request('server_hostname'),
"server_hostname" => strtolower(request('server_hostname')),
"origin" => request('origin'),
])->exists()
) {
Expand All @@ -24,25 +35,14 @@ public function verifyCert()
);
}

$file =
"liman-" .
request('server_hostname') .
"_" .
request('origin') .
".crt";
$cert = file_get_contents('/tmp/' . request('path'));
shell_exec(
"echo '$cert'| sudo tee /usr/local/share/ca-certificates/" .
strtolower($file)
);
shell_exec("sudo update-ca-certificates");

// Create Certificate Object.
$cert = Certificate::create([
$certificate = Certificate::create([
"server_hostname" => strtolower(request('server_hostname')),
"origin" => request('origin'),
]);

$certificate->addToSystem('/tmp/' . request('path'));

// Update Admin Notification
AdminNotification::where('id', request('notification_id'))->update([
"read" => "true",
Expand All @@ -51,6 +51,15 @@ public function verifyCert()
return respond("Sertifika Başarıyla Eklendi!", 200);
}

/**
* @api {post} /sunucu/sertifikaSil Remove SSL Sertificate
* @apiName Remove SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} certificate_id Certificate Id.
*
* @apiSuccess {JSON} message Message with status.
*/
public function removeCert()
{
$certificate = Certificate::where(
Expand All @@ -61,26 +70,23 @@ public function removeCert()
abort(504, "Sertifika bulunamadı");
}

shell_exec(
"sudo rm /usr/local/share/ca-certificates/liman-" .
$certificate->server_hostname .
"_" .
$certificate->origin .
".crt"
);
shell_exec("sudo update-ca-certificates");

Server::where([
'ip_address' => $certificate->server_hostname,
"control_port" => $certificate->origin,
])->update([
"enabled" => "0",
]);
$certificate->removeFromSystem();

$certificate->delete();

return respond("Sertifika Başarıyla Silindi!", 200);
}

/**
* @api {post} /sunucu/sertifikaTalep Request SSL Sertificate
* @apiName Request SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} hostname Target Server' Hostname.
* @apiParam {String} port Target Server' Port.
*
* @apiSuccess {Array} array Requested certificate information..
*/
public function requestCert()
{
list($flag, $message) = retrieveCertificate(
Expand All @@ -94,6 +100,15 @@ public function requestCert()
}
}

/**
* @api {post} /sunucu/sertifikaGuncelle Renew SSL Sertificate
* @apiName Renew SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} certificate_id Certificate id to renew.
*
* @apiSuccess {JSON} message Message with status.
*/
public function updateCert()
{
$certificate = Certificate::where(
Expand All @@ -110,20 +125,11 @@ public function updateCert()
if (!$flag) {
return respond($message, 201);
}
$file =
"liman-" .
$certificate->server_hostname .
"_" .
$certificate->origin .
".crt";
shell_exec('sudo rm /usr/local/share/ca-certificates/ ' . $file);
shell_exec("sudo update-ca-certificates -f");
$cert = file_get_contents('/tmp/' . $message["path"]);
shell_exec(
"echo '$cert'| sudo tee /usr/local/share/ca-certificates/" . $file
);
$certificate->save();
shell_exec("sudo update-ca-certificates -f");

$certificate->removeFromSystem();

$certificate->addToSystem('/tmp/' . $message["path"]);

return respond("Sertifika Başarıyla Güncellendi!");
}
}
19 changes: 11 additions & 8 deletions app/Http/Controllers/Extension/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function allServers()
);
}
// Render View with Cities
return view('extension_pages.index', [
return magicView('extension_pages.index', [
"cities" => implode(',', $cities),
]);
}
Expand Down Expand Up @@ -167,7 +167,7 @@ public function setupNewExtension($zipFile)
// Try to open zip file.
if (!$zip->open($zipFile)) {
system_log(7, "EXTENSION_UPLOAD_FAILED_CORRUPTED");
return respond("Eklenti Dosyası Açılamıyor.", 201);
return [respond("Eklenti Dosyası Açılamıyor.", 201), null];
}

// Determine a random tmp folder to extract files
Expand All @@ -189,11 +189,14 @@ public function setupNewExtension($zipFile)
array_key_exists("supportedLiman", $json) &&
getVersionCode() < intval($json["supportedLiman"])
) {
return respond(
"Bu eklentiyi yükleyebilmek için Liman'ı güncellemelisiniz, gerekli minimum liman sürüm kodu" .
$json["supportedLiman"],
201
);
return [
respond(
"Bu eklentiyi yükleyebilmek için Liman'ı güncellemelisiniz, gerekli minimum liman sürüm kodu" .
$json["supportedLiman"],
201
),
null,
];
}

if (isset($verify)) {
Expand All @@ -208,7 +211,7 @@ public function setupNewExtension($zipFile)
if ($extension) {
if ($extension->version == $json["version"]) {
system_log(7, "EXTENSION_UPLOAD_FAILED_ALREADY_INSTALLED");
return respond("Eklentinin bu sürümü zaten yüklü", 201);
return [respond("Eklentinin bu sürümü zaten yüklü", 201), null];
}
}

Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/Extension/OneController.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,17 @@ public function serverSettingsPage()
}

if (env('LIMAN_RESTRICTED') == true && !user()->isAdmin()) {
return response()->view('extension_pages.setup_restricted', [
return magicView('extension_pages.setup_restricted', [
'extension' => $extension,
'similar' => $similar,
'extensionDb' => extensionDb(),
]);
}

return response()->view('extension_pages.setup', [
return magicView('extension_pages.setup', [
'extension' => $extension,
'similar' => $similar,
'extensionDb' => extensionDb(),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Extension\Sandbox;

use App\Classes\Connector\SSHTunnelConnector;
use App\Connectors\SSHTunnelConnector;
use App\Models\Extension;
use App\Http\Controllers\Controller;
use App\Models\JobHistory;
Expand Down
Loading

0 comments on commit 7105d2b

Please sign in to comment.