Unverified Kaydet (Commit) 67cacfcf authored tarafından Mert ÇELEN's avatar Mert ÇELEN Kaydeden (comit) GitHub

Merge pull request #78 from mertcelen/1.2-dev

Liman'ın Yetkilerinin Kısıtlanması
......@@ -4,7 +4,7 @@ namespace App\Console;
use App\Models\AdminNotification;
use App\Models\Notification;
use App\Models\User;
use App\User;
use App\Http\Controllers\MarketController;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
......
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class ExtensionRendered implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $output;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($output)
{
$this->output = $output;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}
......@@ -9,7 +9,7 @@ use App\Models\UserSettings;
use Carbon\Carbon;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use App\Models\User;
use App\User;
use App\Models\RoleMapping;
use App\Models\RoleUser;
use Illuminate\Support\Facades\Event;
......
......@@ -92,7 +92,7 @@ class MainController extends Controller
} catch (\Exception $exception) {
return respond("Lütfen geçerli bir eklenti giriniz.", 201);
}
$verify = false;
$zipFile = request()->file('extension');
if (
endsWith(
......@@ -146,7 +146,7 @@ class MainController extends Controller
);
}
}
list($error, $new) = self::setupNewExtension($zipFile);
list($error, $new) = self::setupNewExtension($zipFile,$verify);
if ($error) {
return $error;
......@@ -159,7 +159,7 @@ class MainController extends Controller
return respond("Eklenti Başarıyla yüklendi.", 200);
}
public function setupNewExtension($zipFile)
public function setupNewExtension($zipFile, $verify = false)
{
// Initialize Zip Archive Object to use it later.
$zip = new ZipArchive();
......@@ -199,7 +199,7 @@ class MainController extends Controller
];
}
if (isset($verify)) {
if ($verify) {
$json["issuer"] = explode(" ", $verify, 4)[3];
} else {
$json["issuer"] = "";
......@@ -223,55 +223,21 @@ class MainController extends Controller
}
$new->fill($json);
$new->save();
$system = rootSystem();
// Add User if not exists
if (
intval(
shell_exec("grep -c '^" . cleanDash($new->id) . "' /etc/passwd")
)
? false
: true
) {
shell_exec('sudo useradd -r -s /bin/sh ' . cleanDash($new->id));
}
$system->userAdd($new->id);
$extension_folder = "/liman/extensions/" . strtolower($json["name"]);
$passPath = '/liman/keys' . DIRECTORY_SEPARATOR . $new->id;
file_put_contents($passPath, Str::random(32));
shell_exec(
"
sudo chown liman:" .
cleanDash($new->id) .
" $passPath;
sudo chmod 640 $passPath;
sudo mkdir -p $extension_folder;
sudo cp -r " .
$path .
"/* " .
$extension_folder .
DIRECTORY_SEPARATOR .
";
sudo chown " .
cleanDash($new->id) .
":liman $extension_folder;
sudo chmod 770 $extension_folder;
sudo chown -R " .
cleanDash($new->id) .
":liman $extension_folder;
sudo chmod -R 770 $extension_folder;
sudo chown liman:" .
cleanDash($new->id) .
" " .
$extension_folder .
DIRECTORY_SEPARATOR .
"db.json;
sudo chmod 640 " .
$extension_folder .
DIRECTORY_SEPARATOR .
"db.json;
"
);
$extension_folder = "/liman/extensions/" . strtolower($json["name"]);
`mkdir -p $extension_folder`;
`cp -r $path/* $extension_folder/.`;
$system->fixExtensionPermissions($new->id, $new->name);
return [null, $new];
}
......@@ -338,26 +304,12 @@ class MainController extends Controller
json_encode($json, JSON_PRETTY_PRINT)
);
if (
intval(
shell_exec("grep -c '^" . cleanDash($ext->id) . "' /etc/passwd")
)
? false
: true
) {
shell_exec('sudo useradd -r -s /bin/sh ' . cleanDash($ext->id));
}
$system = rootSystem();
$system->userAdd($ext->id);
$passPath = '/liman/keys' . DIRECTORY_SEPARATOR . $ext->id;
file_put_contents($passPath, Str::random(32));
shell_exec(
"
sudo chown liman:" .
cleanDash($ext->id) .
" $passPath;
sudo chmod 640 $passPath;
"
);
request()->request->add(['server' => "none"]);
request()->request->add(['extension_id' => $ext->id]);
......@@ -366,22 +318,7 @@ class MainController extends Controller
touch($folder . "/views/$file");
}
shell_exec(
"
sudo chown -R " .
cleanDash($ext->id) .
":liman $folder;
sudo chmod -R 770 $folder;
sudo chown liman:" .
cleanDash($ext->id) .
" $folder" .
DIRECTORY_SEPARATOR .
"db.json;
sudo chmod 640 $folder" .
DIRECTORY_SEPARATOR .
"db.json;
"
);
$system->fixExtensionPermissions($ext->id, $ext->name);
system_log(6, "EXTENSION_CREATE", [
"extension_id" => $ext->id,
......
......@@ -90,7 +90,7 @@ class OneController extends Controller
$extension["verification"],
$extensionDb
);
$output = shell_exec($command);
$output = rootSystem()->runCommand($command);
if (isJson($output)) {
$message = json_decode($output);
if (isset($message->message)) {
......@@ -251,7 +251,7 @@ class OneController extends Controller
hook('extension_delete_attempt', extension());
try {
shell_exec(
"sudo rm -r " .
"rm -rf " .
"/liman/extensions/" .
strtolower(extension()->name)
);
......@@ -259,18 +259,7 @@ class OneController extends Controller
}
try {
shell_exec(
"
sudo userdel " .
cleanDash(extension()->id) .
";
rm " .
'/liman/keys/' .
DIRECTORY_SEPARATOR .
extension()->id .
";
"
);
rootSystem()->userRemove(extension()->id);
extension()->delete();
} catch (\Exception $exception) {
}
......
......@@ -271,14 +271,8 @@ class InternalController extends Controller
);
// Update Permissions
shell_exec("sudo chmod 770 " . request('localPath'));
shell_exec(
"sudo chown " .
cleanDash(extension()->id) .
":liman " .
request('localPath')
);
rootSystem()->fixExtensionPermissions(extension()->id, extension()->name);
system_log(7, "EXTENSION_INTERNAL_RECEIVE_FILE", [
"extension_id" => extension()->id,
"server_id" => server()->id,
......
......@@ -221,7 +221,7 @@ class MainController extends Controller
$command = $this->sandbox->command($function);
$before = Carbon::now();
$output = shell_exec($command);
$output = rootSystem()->runCommand($command);
return [$output, $before->diffInMilliseconds(Carbon::now()) / 1000];
}
......
......@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Models\LimanRequest;
use App\Models\Server;
use App\Models\User;
use App\User;
use App\Models\UserSettings;
use App\Models\Extension;
use App\Models\Widget;
......
......@@ -6,7 +6,7 @@ use App\Models\AdminNotification;
use App\Models\Notification;
use App\Http\Controllers\Controller;
use App\Notifications\NotificationSent;
use App\Models\User;
use App\User;
class MainController extends Controller
{
......
......@@ -4,7 +4,7 @@ namespace App\Http\Controllers\Permission;
use App\Models\LimanRequest;
use App\Models\Notification;
use App\Models\User;
use App\User;
use App\Http\Controllers\Controller;
class MainController extends Controller
......
......@@ -8,7 +8,7 @@ use App\Models\ConnectorToken;
use App\Models\Extension;
use App\Http\Controllers\Controller;
use App\Models\Notification;
use App\Models\User;
use App\User;
use App\Models\Permission;
use Carbon\Carbon;
use Exception;
......
......@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Settings;
use App\Models\Extension;
use App\Models\Permission;
use App\Models\Server;
use App\Models\User;
use App\User;
use App\Models\Role;
use App\Http\Controllers\Controller;
use App\Models\AdminNotification;
......@@ -69,7 +69,7 @@ class MainController extends Controller
public function getUserList()
{
return view('l.table', [
"value" => \App\Models\User::all(),
"value" => \App\User::all(),
"title" => ["Kullanıcı Adı", "Email", "*hidden*"],
"display" => ["name", "email", "id:user_id"],
"menu" => [
......@@ -611,12 +611,16 @@ input(type=\"imtcp\" port=\"514\")";
{
$data = `grep nameserver /etc/resolv.conf | grep -v "#" | grep nameserver`;
$arr = explode("\n", $data);
$arr = array_filter($arr);
$clean = [];
foreach ($arr as $ip) {
if ($ip == "") {
continue;
}
$foo = explode(" ", trim($ip));
if (count($foo) == 1) {
continue;
}
array_push($clean, $foo[1]);
}
return respond($clean);
......@@ -624,22 +628,13 @@ input(type=\"imtcp\" port=\"514\")";
public function setDNSServers()
{
`sudo chattr -i /etc/resolv.conf`;
$str = "
options rotate timeout:1 retries:1
";
foreach ([request('dns1'), request('dns2'), request('dns3')] as $ip) {
if ($ip == null) {
continue;
}
$str .= "nameserver $ip
";
}
$str = trim($str);
$output = `echo "$str" | sudo tee /etc/resolv.conf`;
$compare = trim(`cat /etc/resolv.conf`) == $str ? true : false;
if ($compare) {
`sudo chattr +i /etc/resolv.conf`;
$system = rootSystem();
$flag = $system->dnsUpdate(
request('dns1'),
request('dns2'),
request('dns3')
);
if ($flag) {
return respond("DNS Ayarları güncellendi!");
} else {
return respond("DNS Ayarları güncellenemedi!", 201);
......
......@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Permission;
use App\Models\RoleUser;
use App\Models\User;
use App\User;
use App\Models\UserSettings;
use App\Models\AccessToken;
use App\Models\Server;
......
......@@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
use Illuminate\Support\Str;
use Jenssegers\Blade\Blade;
use App\System\Helper;
if (!function_exists('respond')) {
/**
* @param $message
......@@ -66,6 +66,13 @@ if (!function_exists('strposX')) {
}
}
if (!function_exists('rootSystem')) {
function rootSystem()
{
return new Helper();
}
}
if (!function_exists('registerModuleRoutes')) {
function registerModuleRoutes()
{
......@@ -363,13 +370,7 @@ if (!function_exists('addCertificate')) {
*/
function addCertificate($hostname, $port, $path)
{
$file = "liman-" . $hostname . "_" . $port . ".crt";
$cert = file_get_contents('/tmp/' . $path);
shell_exec(
"echo '$cert'| sudo tee /usr/local/share/ca-certificates/" .
strtolower($file)
);
shell_exec("sudo update-ca-certificates");
rootSystem()->addCertificate('/tmp/' . $path, "liman-" . $hostname . "_" . $port);
// Create Certificate Object.
return Certificate::create([
......@@ -379,6 +380,16 @@ if (!function_exists('addCertificate')) {
}
}
if (!function_exists('getLimanId')) {
/**
* @return mixed
*/
function getLimanId()
{
return md5("l1m@ns3cur1ty".trim(shell_exec("ls /dev/disk/by-uuid -1"))).PHP_EOL;
}
}
if (!function_exists('system_log')) {
/**
* @param $level
......
<?php
namespace App\Models\Jobs;
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
......@@ -62,13 +62,13 @@ class ExtensionJob implements ShouldQueue
{
$command = $this->sandbox->command($this->function);
$output = shell_exec($command);
$output = rootSystem()->runCommand($command);
system_log(7, "EXTENSION_BACKGROUND_RUN", [
"extension_id" => $this->extension->id,
"server_id" => $this->server->id,
"target_name" => $this->function,
]);
// system_log(7, "EXTENSION_BACKGROUND_RUN", [
// "extension_id" => $this->extension->id,
// "server_id" => $this->server->id,
// "target_name" => $this->function,
// ]);
$code = 200;
try {
......
......@@ -12,22 +12,12 @@ class Certificate extends Model
public function addToSystem($tmpCertLocation)
{
$file =
"liman-" . $this->server_hostname . "_" . $this->origin . ".crt";
$contents = file_get_contents($tmpCertLocation);
shell_exec(
"echo '$contents'| sudo tee /usr/local/share/ca-certificates/" .
strtolower($file)
);
shell_exec("sudo update-ca-certificates");
rootSystem()->addCertificate($tmpCertLocation, "liman-" . $this->server_hostname . "_" . $this->origin);
}
public function removeFromSystem()
{
$file =
"liman-" . $this->server_hostname . "_" . $this->origin . ".crt";
shell_exec('sudo rm /usr/local/share/ca-certificates/ ' . $file);
shell_exec("sudo update-ca-certificates -f");
rootSystem()->removeCertificate("liman-" . $this->server_hostname . "_" . $this->origin);
$this->save();
}
}
......@@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\User;
class Permission extends Model
{
......
......@@ -17,6 +17,6 @@ class Role extends Model
public function users()
{
return $this->belongsToMany('App\Models\User', "role_users");
return $this->belongsToMany('App\User', "role_users");
}
}
......@@ -12,7 +12,7 @@ class RoleUser extends Model
public function user()
{
return $this->belongsTo('App\Models\User');
return $this->belongsTo('App\User');
}
public function role()
......
......@@ -3,7 +3,7 @@
namespace App\Observers;
use App\Models\AdminNotification;
use App\Models\User;
use App\User;
use App\Notifications\NotificationSent;
class AdminNotificationObserver
......
......@@ -3,7 +3,7 @@
namespace App\Observers;
use App\Models\Notification;
use App\Models\User;
use App\User;
use App\Notifications\NotificationSent;
class NotificationObserver
......
......@@ -3,7 +3,7 @@
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use App\User;
use App\Models\Server;
use Illuminate\Auth\Access\HandlesAuthorization;
......@@ -14,7 +14,7 @@ class ServerPolicy
/**
* Determine whether the user can view any servers.
*
* @param \App\Models\User $user
* @param \App\User $user
* @return mixed
*/
public function viewAny(User $user)
......@@ -25,7 +25,7 @@ class ServerPolicy
/**
* Determine whether the user can view the server.
*
* @param \App\Models\User $user
* @param \App\User $user
* @param \App\Models\Server $server
* @return mixed
*/
......@@ -37,7 +37,7 @@ class ServerPolicy
/**
* Determine whether the user can create servers.
*
* @param \App\Models\User $user
* @param \App\User $user
* @return mixed
*/
public function create(User $user)
......@@ -49,7 +49,7 @@ class ServerPolicy
/**
* Determine whether the user can update the server.
*
* @param \App\Models\User $user
* @param \App\User $user
* @param \App\Models\Server $server
* @return mixed
*/
......@@ -61,7 +61,7 @@ class ServerPolicy
/**
* Determine whether the user can delete the server.
*
* @param \App\Models\User $user
* @param \App\User $user
* @param \App\Models\Server $server
* @return mixed
*/
......@@ -73,7 +73,7 @@ class ServerPolicy
/**
* Determine whether the user can restore the server.
*
* @param \App\Models\User $user
* @param \App\User $user
* @param \App\Models\Server $server
* @return mixed
*/
......@@ -85,7 +85,7 @@ class ServerPolicy
/**
* Determine whether the user can permanently delete the server.
*
* @param \App\Models\User $user
* @param \App\User $user
* @param \App\Models\Server $server
* @return mixed
*/
......
......@@ -30,7 +30,7 @@ class AppServiceProvider extends ServiceProvider
Notification::observe(NotificationObserver::class);
AdminNotification::observe(AdminNotificationObserver::class);
Relation::morphMap([
'users' => 'App\Models\User',
'users' => 'App\User',
'roles' => 'App\Models\Role',
]);
......
......@@ -27,5 +27,9 @@ class AuthServiceProvider extends ServiceProvider
public function boot()
{
$this->registerPolicies();
Gate::define('viewWebSocketsDashboard', function ($user = null) {
return false;
});
}
}
<?php
namespace App\System;
use GuzzleHttp\Client;
class Helper {
private $authKey;
private $client;
public function __construct()
{
$this->authKey = file_get_contents("/liman/keys/service.key");
$this->client = new Client([
"base_uri" => "http://127.0.0.1:3008",
]);
}
public function userAdd($extension_id)
{
try{
$this->client->get('/userAdd',[
'query' => [
'extension_id' => cleanDash($extension_id),
'liman_token' => $this->authKey
]
]);
}catch(\Exception $e){
return false;
}
return true;
}
public function userRemove($extension_id)
{
try{
$this->client->get('/userRemove',[
'query' => [
'extension_id' => cleanDash($extension_id),
'liman_token' => $this->authKey
]
]);
}catch(\Exception $e){
return false;
}
return true;
}
public function dnsUpdate($server1, $server2, $server3)
{
try{
$this->client->get('/dns',[
'query' => [
'liman_token' => $this->authKey,
'server1' => $server1 ?: "",
'server2' => $server2 ?: "",
'server3' => $server3 ?: ""
]
]);
}catch(\Exception $e){
return false;
}
return true;
}
public function addCertificate($tmpPath, $targetName)
{
try{
$this->client->get('/certificateAdd',[
'query' => [
'liman_token' => $this->authKey,
'tmpPath' => $tmpPath,
'targetName' => $targetName,
]
]);
}catch(\Exception $e){
return false;
}
return true;
}
public function removeCertificate($targetName)
{
try{
$this->client->get('/certificateRemove',[
'query' => [
'liman_token' => $this->authKey,
'targetName' => $targetName,
]
]);
}catch(\Exception $e){
return false;
}
return true;
}
public function fixExtensionPermissions($extension_id, $extension_name)
{
try{
$this->client->get('/fixPermissions',[
'query' => [
'liman_token' => $this->authKey,
'extension_id' => cleanDash($extension_id),
'extension_name' => strtolower($extension_name)
]
]);
}catch(\Exception $e){
return false;
}
return true;
}
public function runCommand($command)
{
try{
$response = $this->client->get('/extensionRun',[
'query' => [
'liman_token' => $this->authKey,
'command' => $command,
]
]);
}catch(\Exception $e){
return "Unknown System Error";
}
return $response->getBody()->getContents();
}
}
\ No newline at end of file
<?php
namespace App\Models;
namespace App;
use App\Models\Extension;
use App\Models\Permission;
use App\Models\Server;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use App\Models\UsesUuid;
/**
* App\Models\User
* App\User
*
* @property-read mixed $id
* @method static Builder|User newModelQuery()
......
This diff is collapsed.
......@@ -66,7 +66,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
'model' => App\User::class,
],
// 'users' => [
......
......@@ -30,7 +30,7 @@ return [
],
'stripe' => [
'model' => App\Models\User::class,
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
'webhook' => [
......
......@@ -29,7 +29,7 @@ return [
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => true,
'enable_statistics' => true,
'enable_statistics' => false,
],
],
......
......@@ -13,7 +13,7 @@ use Faker\Generator as Faker;
|
*/
$factory->define(App\Models\User::class, function (Faker $faker) {
$factory->define(App\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
......
......@@ -19,13 +19,6 @@ class UpdateExtensionSettings extends Migration
foreach ($extensions as $extension) {
$passPath = '/liman/keys/' . DIRECTORY_SEPARATOR . $extension->id;
file_put_contents($passPath, Str::random(32));
shell_exec(
"sudo chown liman:" .
cleanDash($extension->id) .
" " .
$passPath
);
shell_exec("sudo chmod 640 " . $passPath);
}
// Encrypt Values in Database
......
......@@ -244,7 +244,7 @@ foreach ($extensions as $extension) {
@if(env('EXTENSION_DEVELOPER_MODE') == true)
function extensionDetails(element){
var extension_id = element.querySelector('#extension_id').innerHTML;
partialPageRequest("/eklentiler/" + extension_id);
window.location.href = "/eklentiler/" + extension_id;
}
@endif
</script>
\ No newline at end of file
......@@ -315,7 +315,7 @@
customRequestData["extension_id"] = "{{extension()->id}}";
function editPage(element){
var page = $(element).find("#name").text();
partialPageRequest(location.protocol+'//'+location.host+location.pathname + "/" + page);
window.location.href = location.protocol+'//'+location.host+location.pathname + "/" + page;
}
function updateExtension(type,tableId = null){
......
......@@ -6,13 +6,13 @@
<li class="breadcrumb-item active"><a href="/l/{{extension()->id}}/{{request('city')}}/{{server()->id}}">{{extension()->display_name . __(" - Ana Sayfa")}}</a></li>
</ol>
<div class="right" id="ext_menu" style="float:right;margin-top:-55px">
<button data-toggle="tooltip" title="Eklenti Ayarları" class="btn btn-primary" onclick="partialPageRequest('{{route('extension_server_settings_page',[
<button data-toggle="tooltip" title="Eklenti Ayarları" class="btn btn-primary" onclick="window.location.href = '{{route('extension_server_settings_page',[
"server_id" => server()->id,
"extension_id" => extension()->id
])}}')"><i class="fa fa-cogs"></i></button>
<button data-toggle="tooltip" title="Sunucuya Git" class="btn btn-primary" onclick="partialPageRequest('{{route('server_one',[
])}}'"><i class="fa fa-cogs"></i></button>
<button data-toggle="tooltip" title="Sunucuya Git" class="btn btn-primary" onclick="window.location.href = '{{route('server_one',[
"server_id" => server()->id,
])}}')"><i class="fa fa-server"></i></button>
])}}'"><i class="fa fa-server"></i></button>
@if(count($tokens) > 0)
<button data-toggle="tooltip" title="Sorgu Oluştur" class="btn btn-primary" onclick="showRequestRecords()"><i class="fa fa-book"></i></button>
@endif
......
......@@ -8,41 +8,49 @@
</ol>
</nav>
@include('errors')
<div class="card">
<div class="card-header">
<h3 class="card-title">{{__("Kasa")}}</h3>
</div>
<div class="card-body">
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#add_settings"><i class="fa fa-key "></i> {{__("Anahtar Ekle")}}</button>
<button type="button" class="btn btn-secondary" onclick="cleanSessions()">{{__("Önbelleği Temizle")}}</button>
<div class="tab-pane active" id="settings" style="margin-top: 15px;">
<div class="alert alert-info alert-dismissible">
<h5><i class="icon fas fa-info"></i> {{ __('Bilgilendirme!') }}</h5>
{{__("Güvenliğiniz için varolan verileriniz gösterilmemektedir.")}}
<div class="row">
<div class="col-md-3">
<div class="card card-primary card-outline">
<div class="card-body box-profile">
<h3 class="profile-username text-center">{{__("Kasa")}}</h3>
<p class="text-muted text-center">Bu sayfadan mevcut verilerini görebilirsiniz. Buradaki veriler, eklentiler tarafından kullanılmaktadır.</p>
</div>
@include('table',[
"value" => $settings,
"title" => [
"Ayar Adı" , "Sunucu" , "*hidden*"
],
"display" => [
"name" , "server_name", "id:setting_id"
],
"menu" => [
"Güncelle" => [
"target" => "update_settings",
"icon" => " context-menu-icon-edit"
</div>
</div>
<div class="col-md-9">
<div class="card">
<div class="card-body">
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#add_settings"><i class="fa fa-key "></i> {{__("Anahtar Ekle")}}</button>
<button type="button" class="btn btn-secondary" onclick="cleanSessions()">{{__("Önbelleği Temizle")}}</button>
<div class="tab-pane active" id="settings" style="margin-top: 15px;">
<div class="alert alert-info alert-dismissible">
<h5><i class="icon fas fa-info"></i> {{ __('Bilgilendirme!') }}</h5>
{{__("Güvenliğiniz için varolan verileriniz gösterilmemektedir.")}}
</div>
@include('table',[
"value" => $settings,
"title" => [
"Ayar Adı" , "Sunucu" , "*hidden*"
],
"display" => [
"name" , "server_name", "id:setting_id"
],
"Sil" => [
"target" => "delete_settings",
"icon" => " context-menu-icon-delete"
"menu" => [
"Güncelle" => [
"target" => "update_settings",
"icon" => " context-menu-icon-edit"
],
"Sil" => [
"target" => "delete_settings",
"icon" => " context-menu-icon-delete"
]
]
]
])
])
</div>
</div>
</div>
</div>
</div>
@include('modal',[
"id"=>"add_settings",
"title" => "Anahtar Ekle",
......
......@@ -17,12 +17,12 @@
@case('error')
@case('health_problem')
@case('liman_update')
<a onclick="partialPageRequest('/bildirim/{{$notification->id}}'); return false;" href="/bildirim/{{$notification->id}}" class="dropdown-item" style="color: #f56954;width: 100%">
<a onclick="window.location.href = '/bildirim/{{$notification->id}}'" href="/bildirim/{{$notification->id}}" class="dropdown-item" style="color: #f56954;width: 100%">
{{$notification->title}}
</a>
@break
@default
<a onclick="partialPageRequest('/bildirim/{{$notification->id}}'); return false;" href="/bildirim/{{$notification->id}}" class="dropdown-item" style="color: #00a65a;width: 100%">
<a onclick="window.location.href = '/bildirim/{{$notification->id}}'" href="/bildirim/{{$notification->id}}" class="dropdown-item" style="color: #00a65a;width: 100%">
{{$notification->title}}
</a>
@break
......
......@@ -13,33 +13,5 @@
@endauth
@include('layouts.content')
</div>
<script>
function partialPageRequest(url){
if(url != "/"){
limanEnableWidgets = false;
}
navigateButtons();
history.pushState({}, null, url);
var form = new FormData();
var newUrl = url + "?partialRequest=true";
form.append('partialRequest',true);
request(newUrl,form, function(success){
$(".content-wrapper").html(success);
initialPresets();
},function(error){
var json = JSON.parse(error);
showSwal(json.message,'error',2000);
setTimeout(() => {
history.go(-1);
}, 1500);
},"GET");
}
window.addEventListener('popstate', function (event) {
window.location.href = window.location.hash;
});
</script>
@stop
@endif
\ No newline at end of file
......@@ -2,8 +2,8 @@
<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
<!-- Brand Logo -->
<a href="/" onclick="partialPageRequest('/');return false;" class="brand-link">
<img src="/images/limanlogo.png" height="30" style="opacity: .8;margin-left: 0.3rem;cursor:pointer;" title="Versiyon {{getVersion()}}">
<a href="/" class="brand-link">
<img src="/images/limanlogo.png" height="30" style="opacity: .8;margin-left: 0.3rem;cursor:pointer;" title="Versiyon {{getVersion() . ' Build : ' . getVersionCode()}}">
</a>
<!-- Sidebar -->
<div class="sidebar">
......@@ -26,7 +26,7 @@
</a>
<ul class="nav nav-treeview" @if(request('server_id') == $server->id) style="display: block;" @endif>
<li class="nav-item">
<a onclick="partialPageRequest('/sunucular/{{$server->id}}')" class="nav-link">
<a href="/sunucular/{{$server->id}}" class="nav-link">
<i class="fa fa-info nav-icon"></i>
<p>{{__("Sunucu Detayları")}}</p>
</a>
......@@ -43,7 +43,7 @@
@endforeach
<li class="nav-header">{{__("Sunucular")}}</li>
<li class="nav-item">
<a href='/sunucular' onclick="partialPageRequest('/sunucular');return false;" class="nav-link">
<a href='/sunucular' class="nav-link">
<i class="nav-icon fas fa-server"></i>
<p>{{__("Sunucular")}}</p>
</a>
......@@ -76,20 +76,20 @@
<li class="nav-header">{{__("Yönetim Paneli")}}</li>
@if(\App\Models\Module::exists())
<li class="nav-item">
<a href='/modules' onclick="partialPageRequest('/modules');return false;" class="nav-link">
<a href='/modules' class="nav-link">
<i class="nav-icon fas fa-puzzle-piece"></i>
<p>{{__("Modüller")}}</p>
</a>
</li>
@endif
<li class="nav-item">
<a href='/ayarlar' onclick="partialPageRequest('/ayarlar');return false;" class="nav-link">
<a href='/ayarlar' class="nav-link">
<i class="nav-icon fas fa-cog"></i>
<p>{{__("Sistem Ayarları")}}</p>
</a>
</li>
<li class="nav-item">
<a href='/talepler' onclick="partialPageRequest('/talepler');return false;" class="nav-link">
<a href='/talepler' class="nav-link">
<i class="nav-icon fas fa-plus"></i>
<p>{{__("Yetki Talepleri")}}</p>
@if(\App\Models\LimanRequest::where('status',0)->count())
......@@ -100,7 +100,7 @@
@else
<li class="nav-header">{{__("Yetki Talebi")}}</li>
<li class="nav-item">
<a href='/taleplerim' onclick="partialPageRequest('/taleplerim');return false;" class="nav-link">
<a href='/taleplerim' class="nav-link">
<i class="nav-icon fas fa-key"></i>
<p>{{__("Taleplerim")}}</p>
</a>
......@@ -108,25 +108,25 @@
@endif
<li class="nav-header">{{__("Hesap")}}</li>
<li class="nav-item">
<a href='/profil' onclick="partialPageRequest('/profil');return false;" class="nav-link">
<a href='/profil' class="nav-link">
<i class="nav-icon fas fa-user"></i>
<p>{{__("Profil")}}</p>
</a>
</li>
<li class="nav-item">
<a href='/profil/anahtarlarim' onclick="partialPageRequest('/profil/anahtarlarim');return false" class="nav-link">
<a href='/profil/anahtarlarim' class="nav-link">
<i class="nav-icon fas fa-user-secret"></i>
<p>{{__("Erişim Anahtarları")}}</p>
</a>
</li>
<li class="nav-item">
<a href='/kasa' onclick="partialPageRequest('/kasa');return false;" class="nav-link">
<a href='/kasa' class="nav-link">
<i class="nav-icon fas fa-wallet"></i>
<p>{{__("Kasa")}}</p>
</a>
</li>
<li class="nav-item">
<a href='/bilesenler' onclick="partialPageRequest('/bilesenler');return false;" class="nav-link">
<a href='/bilesenler' class="nav-link">
<i class="nav-icon fas fa-chart-pie"></i>
<p>{{__("Bileşenler")}}</p>
</a>
......
@if(env('LIMAN_RESTRICTED') == true && !user()->isAdmin())
<nav class="main-header navbar navbar-expand navbar-dark" style="margin-left:0px;max-height:60px">
<ul class="navbar-nav" style="line-height:60px;">
<a href="/" onclick="partialPageRequest('/');return false;" class="brand-link">
<a href="/" class="brand-link">
<img src="/images/limanlogo.png" height="30" style="opacity: .8;cursor:pointer;" title="Versiyon {{getVersion()}}">
</a>
<li class="nav-item d-none d-sm-inline-block">
......@@ -75,6 +75,7 @@
<h5 class="widget-user-desc" style="margin-left: 0px;font-size: 13px;">{{__("Son Giriş Tarihi : ") . user()->last_login_at}}</h5>
<h5 class="widget-user-desc" style="margin-left: 0px;font-size: 13px;">{{__("Giriş Yapılan Son Ip : ") . user()->last_login_ip}}</h5>
<h5 class="widget-user-desc" style="margin-left: 0px;font-size: 13px;">{{__("Bağlı Liman : ") . getLimanHostname()}}</h5>
<h5 class="widget-user-desc" style="margin-left: 0px;font-size: 11px;">{{__("Liman ID: ") . getLimanId()}}</h5>
</div>
<div class="card-footer p-0">
<ul class="nav flex-column" style="cursor:pointer;">
......
......@@ -82,7 +82,7 @@ if (!$item) {
var data = new FormData();
data.append('notification_id', $(this).attr('notification-id'));
request('{{route('notification_delete')}}', data, function (response) {
partialPageRequest("{{route('all_user_notifications')}}");
window.location.href = "{{route('all_user_notifications')}}";
}, function(response){
var error = JSON.parse(response);
showSwal(error.message,'error',2000);
......
......@@ -107,7 +107,7 @@ switch ($notification->type) {
var data = new FormData();
data.append('notification_id', $(this).attr('notification-id'));
request('{{route('notification_delete')}}', data, function (response) {
partialPageRequest("{{route('all_user_notifications')}}");
window.location.href = "{{route('all_user_notifications')}}";
}, function(response){
var error = JSON.parse(response);
showSwal(error.message,'error',2000);
......
......@@ -56,7 +56,7 @@
function userSettings(element){
var user_id = element.querySelector('#user_id').innerHTML;
partialPageRequest("/ayarlar/" + user_id);
window.location.href = "/ayarlar/" + user_id;
}
function update(current,status) {
showSwal('{{__("Kaydediliyor.")}}','info');
......
......@@ -310,7 +310,7 @@
keySettingsChanged();
function details(element) {
var server_id = element.querySelector('#server_id').innerHTML;
partialPageRequest("/sunucular/" + server_id);
window.location.href = "/sunucular/" + server_id;
}
$("#keyPasswordCert").fadeOut(0);
$("#certificateInformLabel").fadeOut(0);
......
......@@ -134,7 +134,7 @@
@endif
function logDetails(element) {
var log_id = element.querySelector('#_id').innerHTML;
partialPageRequest("/logs/" + log_id);
window.location.href = "/logs/" + log_id;
}
function favorite(action) {
......@@ -310,7 +310,15 @@
form.append('name',name);
request('{{route('server_service_status')}}', form, function (response) {
var json = JSON.parse(response);
$("#serviceStatusWrapper").html(json.message);
let wrapper = $("#serviceStatusWrapper");
wrapper.html(json.message);
if(json.message.includes("Active: active (running)")) {
wrapper.css("color","green");
}else if(json.message.includes("Active: inactive (dead)")) {
wrapper.css("color","grey");
}else if(json.message.includes("Active: failed")) {
wrapper.css("color","red");
}
$("#serviceStatusModal").modal('show');
setTimeout(function () {
Swal.close();
......
......@@ -3,8 +3,8 @@
@section('content')
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{route('home')}}" onclick="partialPageRequest('{{route('home')}}');return false;">{{__("Ana Sayfa")}}</a></li>
<li class="breadcrumb-item"><a href="{{route('servers')}}" onclick="partialPageRequest('{{route('servers')}}');return false;">{{__("Sunucular")}}</a></li>
<li class="breadcrumb-item"><a href="{{route('home')}}">{{__("Ana Sayfa")}}</a></li>
<li class="breadcrumb-item"><a href="{{route('servers')}}">{{__("Sunucular")}}</a></li>
<li class="breadcrumb-item active" aria-current="page">{{$server->name}}</li>
</ol>
</nav>
......
......@@ -138,7 +138,7 @@
var json = JSON.parse(success);
showSwal(json["message"],'info',2000);
setTimeout(function () {
partialPageRequest("{{route('settings')}}" + "#certificates");
window.location.href = "{{route('settings')}}" + "#certificates";
},1000);
},function (errors) {
var json = JSON.parse(errors);
......
......@@ -63,7 +63,7 @@
])<br><br>
<div id="usersTable">
@include('table',[
"value" => \App\Models\User::all(),
"value" => \App\User::all(),
"title" => [
"Kullanıcı Adı" , "Email" , "*hidden*" ,
],
......@@ -95,7 +95,7 @@
</div>
</div>
<div class="tab-pane fade show" id="certificates" role="tabpanel">
<button class="btn btn-success" onclick="partialPageRequest('{{route('certificate_add_page')}}')"><i
<button class="btn btn-success" onclick="window.location.href = '{{route('certificate_add_page')}}'"><i
class="fa fa-plus"></i> {{__("Sertifika Ekle")}}</button>
<br><br>
@include('table',[
......@@ -751,7 +751,7 @@
function afterUserAdd(response) {
var json = JSON.parse(response);
$("#add_user button[type='submit']").attr("disabled","true")
getUserList();
//getUserList();
}
$(function () {
......@@ -762,7 +762,7 @@
function getUserList(){
request('{{route('get_user_list_admin')}}', new FormData(), function (response) {
$("#usersTable").html(response);
$('#usersTable table').DataTable(dataTablePresets('multiple'));
$('#usersTable table').DataTable();
}, function(response){
var error = JSON.parse(response);
showSwal(error.message,'error',2000);
......@@ -782,12 +782,12 @@
function roleDetails(row){
var role_id = row.querySelector('#role_id').innerHTML;
partialPageRequest('/rol/' + role_id);
window.location.href = '/rol/' + role_id;
}
function userDetails(row) {
var user_id = row.querySelector('#user_id').innerHTML;
partialPageRequest('/ayarlar/' + user_id);
window.location.href = '/ayarlar/' + user_id;
}
function checkHealth() {
......
......@@ -220,7 +220,7 @@
"title" =>"Kullanıcıyı Sil",
"url" => route('user_remove'),
"text" => "Kullanıcıyı silmek istediğinize emin misiniz? Bu işlem geri alınamayacaktır.",
"next" => "redirect",
"next" => "redirectToSettings",
"inputs" => [
"Kullanici Id:'null'" => "user_id:hidden"
],
......@@ -328,6 +328,10 @@
showSwal(error.message,'error',2000);
})
}
function redirectToSettings() {
window.location.href = "{{route('settings')}}";
}
function removeRole(element){
var data = [];
var table = $("#role_table").DataTable();
......@@ -456,7 +460,7 @@
function roleDetails(row){
var role_id = row.querySelector('#role_id').innerHTML;
partialPageRequest('/rol/' + role_id);
window.location.href = '/rol/' + role_id;
}
var currentPermissionId = null;
function permissionData(row){
......
......@@ -19,7 +19,7 @@
<div class="col-md-9">
<div class="card">
<div class="card-body">
<button class="btn btn-success" onclick="partialPageRequest('{{route('widget_add_page')}}')">{{__("Bileşen Ekle")}}</button>
<button class="btn btn-success" onclick="window.location.href = '{{route('widget_add_page')}}'">{{__("Bileşen Ekle")}}</button>
<br><br>
@include('errors')
<?php foreach ($widgets as $widget) {
......@@ -41,10 +41,6 @@
"server_name" , "title" ,"extension_name", "id:widget_id"
],
"menu" => [
"Düzenle" => [
"target" => "edit",
"icon" => " context-menu-icon-edit"
],
"Sil" => [
"target" => "delete",
"icon" => " context-menu-icon-delete"
......@@ -71,21 +67,6 @@
"submit_text" => "Ekle"
])
@include('modal',[
"id"=>"edit",
"title" => "Bileşen Düzenle",
"url" => route('widget_update'),
"next" => "updateTable",
"inputs" => [
"Sunucu Seçin:server_id" => objectToArray(servers(),"name","id"),
"Eklenti Seçin:extension_id" => objectToArray(extensions(),"name","id"),
"Başlık" => "title:text",
"type:-" => "type:hidden",
"display_type:-" => "display_type:hidden",
"widget_id:widget_id" => "widget_id:hidden"
],
"submit_text" => "Düzenle"
])
@include('modal',[
"id"=>"delete",
......
<?php
use App\Models\User;
use App\User;
use App\Models\Module;
use App\Models\AdminNotification;
use Illuminate\Support\Facades\Hash;
......
......@@ -155,14 +155,7 @@ Route::any('/upload/{any?}', function () {
}
if (!file_exists($path . "/uploads")) {
mkdir($path . "/uploads");
shell_exec(
"sudo chown " .
cleanDash($extension_id) .
":liman " .
$path .
"/uploads"
);
shell_exec("sudo chmod 770 " . $path . "/uploads");
rootSystem()->fixExtensionPermissions($extension_id, $extension->name);
}
$server->setUploadDir($path . "/uploads");
$response = $server->serve();
......@@ -179,6 +172,7 @@ Route::post('/upload_info', function () {
$server = app('tus-server');
$info = $server->getCache()->get($key);
$extension_id = request("extension_id");
$extension = \App\Models\Extension::find($extension_id);
if ($extension_id) {
$extension_path = explode("/uploads/", $info['file_path'], 2)[0];
$info['file_path'] = str_replace(
......@@ -186,13 +180,7 @@ Route::post('/upload_info', function () {
'',
$info['file_path']
);
shell_exec(
"sudo chown " .
cleanDash($extension_id) .
":liman " .
$info['file_path']
);
shell_exec("sudo chmod 770 " . $info['file_path']);
rootSystem()->fixExtensionPermissions($extension_id, $extension->name);
}
return $info;
})->middleware(['auth', 'permissions']);
......
1.1.7a
\ No newline at end of file
1.2.0
\ No newline at end of file
......@@ -14,18 +14,21 @@ fi
# User Creation
if getent passwd liman > /dev/null 2>&1; then
sed -i '/liman/d' /etc/sudoers
echo "liman ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
#sed -i '/liman/d' /etc/sudoers
#echo "liman ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
echo "Liman User Found."
else
useradd liman -m
mkdir /home/liman
chmod -R o= /liman /home/liman
chown -R liman:liman /liman /home/liman
echo "liman ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
#echo "liman ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
echo "Liman User Created"
fi
# Delete if sudo exists
sed -i '/liman/d' /etc/sudoers
runuser liman -c '$(which gpg) --import /liman/server/storage/aciklab.public'
# Certificate Creation
......@@ -133,9 +136,6 @@ php /liman/server/artisan cache:clear
php /liman/server/artisan view:clear
php /liman/server/artisan config:clear
# Clear Sandbox Cache
rm -rf /tmp/liman
# Delete Old Sandbox Files
rm -rf /liman/sandbox/{.git,vendor,views,.gitignore,composer.json,composer.lock,index.php}
......@@ -147,7 +147,7 @@ chown liman:liman /{liman,liman/extensions,liman/keys}
chmod 755 /{liman,liman/extensions,liman/keys}
# Create Systemd Service
if [ -f "/etc/systemd/system/liman.service" ]; then
if [ -f "/etc/systemd/system/liman-connector.service" ]; then
echo "Liman Connector Service Already Added.";
else
echo """
......@@ -164,7 +164,28 @@ ExecStart=/liman/server/storage/connector
[Install]
WantedBy=multi-user.target
""" > /etc/systemd/system/liman.service
""" > /etc/systemd/system/liman-connector.service
fi
# Create Systemd Service
if [ -f "/etc/systemd/system/liman-system.service" ]; then
echo "Liman Connector Service Already Added.";
else
echo """
[Unit]
Description=Liman System Service & Extension Renderer
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/liman/server/storage/liman_system
[Install]
WantedBy=multi-user.target
""" > /etc/systemd/system/liman-system.service
fi
# Create Systemd Service
......@@ -208,17 +229,6 @@ WantedBy=multi-user.target
""" > /etc/systemd/system/liman-vnc.service
fi
sed -i "s/upload_max_filesize.*/upload_max_filesize = 50M/g" /etc/php/7.3/fpm/php.ini
sed -i "s/post_max_size.*/post_max_size = 50M/g" /etc/php/7.3/fpm/php.ini
systemctl daemon-reload
systemctl enable liman
systemctl enable liman-vnc
systemctl enable liman-webssh
systemctl restart liman
systemctl restart liman-vnc
systemctl restart liman-webssh
systemctl reload php7.3-fpm.service
# Create Socket Service
if [ -f "/etc/systemd/system/liman-socket.service" ]; then
echo "Liman Socket Service Already Added.";
......@@ -239,9 +249,9 @@ ExecStart=/usr/bin/php /liman/server/artisan websockets:serve --host=127.0.0.1
WantedBy=multi-user.target
""" > /etc/systemd/system/liman-socket.service
fi
systemctl daemon-reload
systemctl enable liman-socket
systemctl restart liman-socket
sed -i "s/upload_max_filesize.*/upload_max_filesize = 100M/g" /etc/php/7.3/fpm/php.ini
sed -i "s/post_max_size.*/post_max_size = 100M/g" /etc/php/7.3/fpm/php.ini
# Prepare Folders for vnc
rm -rf /liman/keys/vnc
......@@ -251,10 +261,28 @@ touch /liman/keys/vnc/config
chown liman:liman /liman/keys/vnc /liman/keys/vnc/config
chmod 700 /liman/keys/vnc/config
# Restart and enable services.
# Reload the systemd
systemctl daemon-reload
# Remove Legacy Service.
rm /etc/systemd/system/liman.service 2>/dev/null
systemctl disable liman 2>/dev/null
systemctl stop liman 2>/dev/null
systemctl enable liman-vnc 2>/dev/null
systemctl enable liman-webssh 2>/dev/null
systemctl enable liman-system 2>/dev/null
systemctl enable liman-connector 2>/dev/null
systemctl enable liman-socket 2>/dev/null
systemctl enable nginx 2>/dev/null
systemctl enable php7.3-fpm 2>/dev/null
systemctl restart liman-connector
systemctl restart liman-system
systemctl restart liman-vnc
systemctl restart liman-webssh
systemctl restart liman-socket
systemctl restart nginx
systemctl enable nginx
systemctl enable php7.3-fpm
systemctl restart php7.3-fpm
# Optimize Liman
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment