mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-21 08:25:45 +00:00
fix(api): expose sensitive fields for privileged tokens
Privileged API tokens can read hidden resource fields in environment and resource responses, including instance-admin team tokens with team_id 0. Configuration hashes now include hidden environment variable values so secret edits trigger restart detection.
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Enums\StaticImageTypes;
|
||||
use App\Rules\ValidGitBranch;
|
||||
use App\Support\ValidationPatterns;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -87,6 +88,20 @@ function serializeApiResponse($data)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-expose a model's `$hidden` sensitive fields when the current API request
|
||||
* carries the `read:sensitive` or `root` token ability (set by the
|
||||
* ApiSensitiveData middleware).
|
||||
*/
|
||||
function exposeSensitiveFields(Model $model): Model
|
||||
{
|
||||
if (request()->attributes->get('can_read_sensitive', false) === true && filled($model->getHidden())) {
|
||||
$model->makeVisible($model->getHidden());
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
function sharedDataApplications()
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user