# overrides can be made. Defaults to disabled.
APP_THEME=false
+# Trusted Proxies
+# Used to indicate trust of systems that proxy to the application so
+# certain header values (Such as "X-Forwarded-For") can be used from the
+# incoming proxy request to provide origin detail.
+# Set to an IP address, or multiple comma seperated IP addresses.
+# Can alternatively be set to "*" to trust all proxy addresses.
+APP_PROXIES=null
+
# Database details
# Host can contain a port (localhost:3306) or a separate DB_PORT option can be used.
DB_HOST=localhost
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-class AddColumnIpIntoActivities extends Migration
+class AddActivitiesIpColumn extends Migration
{
/**
* Run the migrations.
{
Schema::table('activities', function (Blueprint $table) {
$table->string('ip', 45)->after('user_id');
-
- $table->index(['ip'], 'user_ip_idx');
});
}
public function down()
{
Schema::table('activities', function (Blueprint $table) {
- $table->dropIndex('user_ip_idx');
$table->dropColumn('ip');
});
}
'audit_deleted_item' => 'Deleted Item',
'audit_deleted_item_name' => 'Name: :name',
'audit_table_user' => 'User',
- 'audit_table_user_ip' => 'User IP',
'audit_table_event' => 'Event',
'audit_table_related' => 'Related Item or Detail',
+ 'audit_table_ip' => 'IP Address',
'audit_table_date' => 'Activity Date',
'audit_date_from' => 'Date Range From',
'audit_date_to' => 'Date Range To',
$resp->assertSeeText($chapter->name);
$resp->assertDontSeeText($page->name);
}
+
+ public function test_ip_address_logged_and_visible()
+ {
+ config()->set('app.proxies', '*');
+ $editor = $this->getEditor();
+ /** @var Page $page */
+ $page = Page::query()->first();
+
+ $this->actingAs($editor)->put($page->getUrl(), [
+ 'name' => 'Updated page',
+ 'html' => '<p>Updated content</p>',
+ ], [
+ 'X-Forwarded-For' => '192.123.45.1'
+ ])->assertRedirect($page->refresh()->getUrl());
+
+ $this->assertDatabaseHas('activities', [
+ 'type' => ActivityType::PAGE_UPDATE,
+ 'ip' => '192.123.45.1',
+ 'user_id' => $editor->id,
+ 'entity_id' => $page->id,
+ ]);
+
+ $resp = $this->asAdmin()->get('/settings/audit');
+ $resp->assertSee('192.123.45.1');
+ }
+
+ public function test_ip_address_not_logged_in_demo_mode()
+ {
+ config()->set('app.proxies', '*');
+ config()->set('app.env', 'demo');
+ $editor = $this->getEditor();
+ /** @var Page $page */
+ $page = Page::query()->first();
+
+ $this->actingAs($editor)->put($page->getUrl(), [
+ 'name' => 'Updated page',
+ 'html' => '<p>Updated content</p>',
+ ], [
+ 'X-Forwarded-For' => '192.123.45.1',
+ 'REMOTE_ADDR' => '192.123.45.2',
+ ])->assertRedirect($page->refresh()->getUrl());
+
+ $this->assertDatabaseHas('activities', [
+ 'type' => ActivityType::PAGE_UPDATE,
+ 'ip' => '127.0.0.1',
+ 'user_id' => $editor->id,
+ 'entity_id' => $page->id,
+ ]);
+ }
}