mirror of
https://github.com/pelican-dev/panel.git
synced 2026-02-09 19:07:58 +03:00
Compare commits
1 Commits
main
...
lance/2187
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c0803d2a0 |
@@ -34,10 +34,6 @@ class ProcessWebhook implements ShouldQueue
|
||||
$data = reset($data);
|
||||
}
|
||||
|
||||
if (is_object($data)) {
|
||||
$data = get_object_vars($data);
|
||||
}
|
||||
|
||||
if (is_string($data)) {
|
||||
$data = Arr::wrap(json_decode($data, true) ?? []);
|
||||
}
|
||||
|
||||
@@ -31,22 +31,13 @@ class GetUserPermissionsService
|
||||
'admin.websocket.transfer',
|
||||
];
|
||||
|
||||
if ($isAdmin && ($isOwner || $user->can('update', $server))) {
|
||||
return array_merge(['*'], $adminPermissions);
|
||||
if ($isAdmin) {
|
||||
return $isOwner || $user->can('update', $server) ? array_merge(['*'], $adminPermissions) : array_merge([SubuserPermission::WebsocketConnect->value], $adminPermissions);
|
||||
}
|
||||
|
||||
/** @var Subuser|null $subuser */
|
||||
$subuser = $server->subusers()->where('user_id', $user->id)->first();
|
||||
$subuserPermissions = $subuser !== null ? $subuser->permissions : [];
|
||||
|
||||
if ($isAdmin) {
|
||||
return array_unique(array_merge(
|
||||
[SubuserPermission::WebsocketConnect->value],
|
||||
$adminPermissions,
|
||||
$subuserPermissions,
|
||||
));
|
||||
}
|
||||
|
||||
return $subuserPermissions;
|
||||
return $subuser->permissions ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
document.getElementById(monacoId).editor = monaco.editor.create($refs.monacoEditorElement, {
|
||||
value: monacoContent,
|
||||
theme: localStorage.getItem('theme') === 'light' ? 'iPlastic' : 'custom',
|
||||
fontFamily: 'Consolas, \'Courier New\', \'Noto Sans Mono\', \'DejaVu Sans Mono\', monospace',
|
||||
fontSize: monacoFontSize,
|
||||
lineNumbersMinChars: lineNumbersMinChars,
|
||||
automaticLayout: automaticLayout,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<x-filament-panels::page>
|
||||
@once
|
||||
<style>
|
||||
.fi-ta-header-ctn {
|
||||
.files-selection-merged .fi-ta-header-ctn {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
|
||||
@@ -11,7 +11,6 @@ use App\Models\User;
|
||||
use App\Models\UserSSHKey;
|
||||
use App\Tests\Integration\IntegrationTestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class SftpAuthenticationControllerTest extends IntegrationTestCase
|
||||
{
|
||||
@@ -196,39 +195,6 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase
|
||||
$this->post('/api/remote/sftp/auth', $data)->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_subuser_sftp_works_when_user_has_view_only_role(): void
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount([SubuserPermission::FileRead, SubuserPermission::FileSftp]);
|
||||
|
||||
$user->update(['password' => password_hash('foobar', PASSWORD_DEFAULT)]);
|
||||
|
||||
$this->setAuthorization($server->node);
|
||||
|
||||
$data = [
|
||||
'username' => $user->username . '.' . $server->uuid_short,
|
||||
'password' => 'foobar',
|
||||
];
|
||||
|
||||
// SFTP works as a plain subuser
|
||||
$this->postJson('/api/remote/sftp/auth', $data)
|
||||
->assertOk()
|
||||
->assertJsonPath('permissions', [SubuserPermission::FileRead->value, SubuserPermission::FileSftp->value]);
|
||||
|
||||
// Assign a role with only "view server" permission
|
||||
$role = Role::findOrCreate('view-only-test', 'web');
|
||||
$permission = Permission::findOrCreate('view server', 'web');
|
||||
$role->givePermissionTo($permission);
|
||||
$user->syncRoles($role);
|
||||
|
||||
// SFTP should still work — subuser permissions must be merged with admin permissions
|
||||
$response = $this->postJson('/api/remote/sftp/auth', $data)
|
||||
->assertOk();
|
||||
|
||||
$permissions = $response->json('permissions');
|
||||
$this->assertContains(SubuserPermission::FileSftp->value, $permissions);
|
||||
$this->assertContains(SubuserPermission::FileRead->value, $permissions);
|
||||
}
|
||||
|
||||
public static function authorizationTypeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user