-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add impersonate #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.x
Are you sure you want to change the base?
Changes from all commits
3b6fd3c
0c4e554
9a8ce65
b9f02cd
3910111
e883152
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ | |
| "predis/predis": "^2.4.1", | ||
| "ryangjchandler/commonmark-blade-block": "^1.1", | ||
| "spatie/laravel-medialibrary": "^11.17.5", | ||
| "stechstudio/filament-impersonate": "^4.0", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: stechstudio/filament-impersonate — summary
Install: composer require stechstudio/filament-impersonate. [1] Sources: Packagist package page and project GitHub. [1][2] 🏁 Script executed: #!/bin/bash
# Check what files changed in this PR to see if implementation code is included
git diff --name-only HEAD~1 HEAD 2>/dev/null | head -20 || echo "Git history not available"
# Also check composer.json to see all changes
git diff HEAD~1 HEAD composer.json 2>/dev/null || echo "Could not get git diff"Repository: he4rt/he4rt-bot-api Length of output: 85 🌐 Web query:
💡 Result: I found no CVE or public security advisory specifically for stechstudio/filament-impersonate. The repository itself is active on GitHub [1]. The notable Filament security issues that do have CVEs (e.g., CVE-2024-47186 affecting Filament core color components) are for the Filament project, not the stechstudio/filament-impersonate plugin [2]. Public CVE aggregators and advisories list Filament/core vulnerabilities but do not show a CVE entry for stechstudio/filament-impersonate [3]. If you want, I can:
Sources: GitHub repo (stechstudio/filament-impersonate) [1]; Filament CVE example (CVE-2024-47186) analysis [2]; CVE/advisory aggregator listings (no CVE for that plugin) [3]. 🏁 Script executed: #!/bin/bash
# Check if there are any implementation files for impersonate feature
# Look for config files, middleware, routes, controllers, or service providers
echo "=== Checking for impersonate-related implementation files ==="
fd -e php | xargs grep -l "impersonate\|Impersonate" 2>/dev/null | head -20
echo ""
echo "=== Checking for new files in config directory ==="
find . -path ./vendor -prune -o -type f -name "*impersonate*" -print 2>/dev/null
echo ""
echo "=== Checking composer.json changes ==="
cat composer.json | grep -A2 -B2 "filament-impersonate"Repository: he4rt/he4rt-bot-api Length of output: 471 PR adds only the composer dependency; implementation code is missing. The package However, this PR contains only the composer.json change. No implementation files (config, routes, middleware, service provider registration, etc.) were added. The impersonate feature will not function until these are included. 🤖 Prompt for AI Agents |
||
| "symfony/browser-kit": "v7.0.8", | ||
| "torchlight/torchlight-commonmark": "^0.6.0", | ||
| "torchlight/torchlight-laravel": "^0.6.1" | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,6 +50,21 @@ public function run(): void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->recycle($tenant) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->createOne(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| User::factory() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->count(5) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->create() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->each(function (User $user, $index) use ($tenant): void { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $idx = $index + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $user->update([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'username' => 'fake_user_'.$idx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'name' => 'Fake User '.$idx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Character::factory()->recycle($user)->recycle($tenant)->create(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Information::factory()->recycle($user)->create(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Address::factory()->recycle($user)->create(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Provider::factory()->recycle($user)->recycle($tenant)->create(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+53
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New users are not attached as tenant members. The admin user is attached to the tenant via Consider attaching new users to the tenant: User::factory()
->count(5)
->create()
->each(function (User $user, $index) use ($tenant): void {
$idx = $index + 1;
$user->update([
'username' => 'fake_user_'.$idx,
'name' => 'Fake User '.$idx,
]);
+ $tenant->members()->attach($user);
Character::factory()->recycle($user)->recycle($tenant)->create();
Information::factory()->recycle($user)->create();
Address::factory()->recycle($user)->create();
Provider::factory()->recycle($user)->recycle($tenant)->create();
});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventModel::factory() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->withStatus() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->recycle($tenant) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 101
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 105
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 5473
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 111
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 115
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 4051
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 45
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 45
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 152
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 1247
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 47
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 45
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 494
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 1951
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 45
🏁 Script executed:
Repository: he4rt/he4rt-bot-api
Length of output: 126
Consider adding a fallback for edge cases where tenant becomes null or is unexpectedly missing.
The code uses
$record->character(aHasOnerelationship returning one character per user), so the concern about multiple characters across tenants is not architecturally enforced at the model level. However, while thevisible()guard checks for a non-null tenant slug, theredirectTo()callback could theoretically receive a null$tenantNameif the tenant relationship is unexpectedly missing or becomes null between the two checks, resulting in '/app/' as the redirect target.The suggested defensive fallback is reasonable:
Impersonate::make() ->visible(fn (User $record) => (bool) $record->character?->tenant?->slug) ->redirectTo(function (User $record): string { - $tenantName = $record->character?->tenant?->slug; + $tenantName = $record->character?->tenant?->slug ?? ''; + + if (empty($tenantName)) { + return '/admin'; + } return '/app/'.$tenantName; }),📝 Committable suggestion
🤖 Prompt for AI Agents