diff --git a/app/Livewire/Security/ApiTokens.php b/app/Livewire/Security/ApiTokens.php index ff8679d21..1a0ca51ef 100644 --- a/app/Livewire/Security/ApiTokens.php +++ b/app/Livewire/Security/ApiTokens.php @@ -2,6 +2,7 @@ namespace App\Livewire\Security; +use App\Models\InstanceSettings; use Livewire\Component; class ApiTokens extends Component @@ -16,13 +17,18 @@ class ApiTokens extends Component public array $permissions = ['read-only']; + public $instanceSettings; + public function render() { - return view('livewire.security.api-tokens'); + return view('livewire.security.api-tokens', [ + 'instanceSettings' => $this->instanceSettings, + ]); } public function mount() { + $this->instanceSettings = InstanceSettings::get(); $this->tokens = auth()->user()->tokens->sortByDesc('created_at'); } diff --git a/database/migrations/2024_09_26_083441_disable_api_by_default.php b/database/migrations/2024_09_26_083441_disable_api_by_default.php new file mode 100644 index 000000000..d0803f751 --- /dev/null +++ b/database/migrations/2024_09_26_083441_disable_api_by_default.php @@ -0,0 +1,18 @@ +boolean('is_api_enabled')->default(false)->change(); + }); + } +}; diff --git a/resources/views/livewire/security/api-tokens.blade.php b/resources/views/livewire/security/api-tokens.blade.php index 48f68d9d7..3da3a2dbe 100644 --- a/resources/views/livewire/security/api-tokens.blade.php +++ b/resources/views/livewire/security/api-tokens.blade.php @@ -1,79 +1,71 @@
API Tokens | Coolify - - -
-

API Tokens

-
Tokens are created with the current team as scope. You will only have access to this team's resources. -
-
-

New Token

-
-
- - Create New Token -
-
- Permissions : -
- @if ($permissions) - @foreach ($permissions as $permission) - @if ($permission === '*') -
All (root/admin access), be careful!
- @else -
{{ $permission }}
- @endif - @endforeach - @endif + + +
+

API Tokens

+ @if (!$instanceSettings->is_api_enabled) + API is disabled. If you want to use the API, please enable it in the Coolify Instance Settings. + @else +
Tokens are created with the current team as scope. You will only have access to this team's resources.
-

Token Permissions

-
- - -
- - @if (session()->has('token')) +

New Token

+
+
+ + Create New Token +
+
+ Permissions + : +
+ @if ($permissions) + @foreach ($permissions as $permission) + @if ($permission === '*') +
All (root/admin access), be careful!
+ @else +
{{ $permission }}
+ @endif + @endforeach + @endif +
+
+

Token Permissions

+
+ + +
+
+ @if (session()->has('token'))
Please copy this token now. For your security, it won't be shown again.
{{ session('token') }}
- @endif -

Issued Tokens

-
- @forelse ($tokens as $token) + @endif +

Issued Tokens

+
+ @forelse ($tokens as $token)
Description: {{ $token->name }}
Last used: {{ $token->last_used_at ? $token->last_used_at->diffForHumans() : 'Never' }}
@if ($token->abilities) - Abilities: - @foreach ($token->abilities as $ability) -
{{ $ability }}
- @endforeach + Abilities: + @foreach ($token->abilities as $ability) +
{{ $ability }}
+ @endforeach @endif
- +
- @empty + @empty
No API tokens found.
- @endforelse -
- + @endforelse +
+ @endif