Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117763608
D3734.1775219832.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
17 KB
Referenced Files
None
Subscribers
None
D3734.1775219832.diff
View Options
diff --git a/src/app/Http/Controllers/API/V4/NGINXController.php b/src/app/Http/Controllers/API/V4/NGINXController.php
--- a/src/app/Http/Controllers/API/V4/NGINXController.php
+++ b/src/app/Http/Controllers/API/V4/NGINXController.php
@@ -193,7 +193,7 @@
// All checks passed
switch ($request->headers->get('Auth-Protocol')) {
case "imap":
- return $this->authenticateIMAP($request, $user->getSetting('guam_enabled', false), $password);
+ return $this->authenticateIMAP($request, (bool) $user->getSetting('guam_enabled'), $password);
case "smtp":
return $this->authenticateSMTP($request, $password);
default:
diff --git a/src/app/Traits/UserConfigTrait.php b/src/app/Traits/UserConfigTrait.php
--- a/src/app/Traits/UserConfigTrait.php
+++ b/src/app/Traits/UserConfigTrait.php
@@ -11,10 +11,17 @@
*/
public function getConfig(): array
{
- $settings = $this->getSettings(['greylist_enabled', 'password_policy', 'max_password_age', 'limit_geo']);
+ $settings = $this->getSettings([
+ 'greylist_enabled',
+ 'guam_enabled',
+ 'password_policy',
+ 'max_password_age',
+ 'limit_geo'
+ ]);
$config = [
'greylist_enabled' => $settings['greylist_enabled'] !== 'false',
+ 'guam_enabled' => $settings['guam_enabled'] === 'true',
'limit_geo' => $settings['limit_geo'] ? json_decode($settings['limit_geo'], true) : [],
'max_password_age' => $settings['max_password_age'],
'password_policy' => $settings['password_policy'],
@@ -37,6 +44,8 @@
foreach ($config as $key => $value) {
if ($key == 'greylist_enabled') {
$this->setSetting($key, $value ? 'true' : 'false');
+ } elseif ($key == 'guam_enabled') {
+ $this->setSetting($key, $value ? 'true' : null);
} elseif ($key == 'limit_geo') {
if (!is_array($value)) {
$errors[$key] = \trans('validation.invalid-limit-geo');
diff --git a/src/resources/lang/en/ui.php b/src/resources/lang/en/ui.php
--- a/src/resources/lang/en/ui.php
+++ b/src/resources/lang/en/ui.php
@@ -461,6 +461,8 @@
'greylisting-text' => "Greylisting is a method of defending users against spam. Any incoming mail from an unrecognized sender "
. "is temporarily rejected. The originating server should try again after a delay. "
. "This time the email will be accepted. Spammers usually do not reattempt mail delivery.",
+ 'imapproxy' => "IMAP proxy",
+ 'imapproxy-text' => "Enables IMAP proxy that filters out non-mail groupware folders, so your IMAP clients do not see them.",
'list-title' => "User accounts",
'list-empty' => "There are no users in this account.",
'managed-by' => "Managed by",
diff --git a/src/resources/vue/Admin/User.vue b/src/resources/vue/Admin/User.vue
--- a/src/resources/vue/Admin/User.vue
+++ b/src/resources/vue/Admin/User.vue
@@ -206,6 +206,15 @@
</div>
</div>
<div class="row plaintext">
+ <label for="guam_enabled" class="col-sm-4 col-form-label">{{ $t('user.imapproxy') }}</label>
+ <div class="col-sm-8">
+ <span class="form-control-plaintext" id="guam_enabled">
+ <span v-if="user.config.guam_enabled" class="text-success">{{ $t('form.enabled') }}</span>
+ <span v-else class="text-danger">{{ $t('form.disabled') }}</span>
+ </span>
+ </div>
+ </div>
+ <div class="row plaintext">
<label for="limit_geo" class="col-sm-4 col-form-label">{{ $t('user.geolimit') }}</label>
<div class="col-sm-8">
<span class="form-control-plaintext" id="limit_geo">
diff --git a/src/resources/vue/User/Info.vue b/src/resources/vue/User/Info.vue
--- a/src/resources/vue/User/Info.vue
+++ b/src/resources/vue/User/Info.vue
@@ -93,6 +93,18 @@
</small>
</div>
</div>
+ <div v-if="$root.hasPermission('beta')" class="row checkbox mb-3">
+ <label for="guam_enabled" class="col-sm-4 col-form-label">
+ {{ $t('user.imapproxy') }}
+ <sup class="badge bg-primary">{{ $t('dashboard.beta') }}</sup>
+ </label>
+ <div class="col-sm-8 pt-2">
+ <input type="checkbox" id="guam_enabled" name="guam_enabled" value="1" class="form-check-input d-block mb-2" :checked="user.config.guam_enabled">
+ <small id="guam-hint" class="text-muted">
+ {{ $t('user.imapproxy-text') }}
+ </small>
+ </div>
+ </div>
<div v-if="$root.hasPermission('beta')" class="row mb-3">
<label for="limit_geo" class="col-sm-4 col-form-label">
{{ $t('user.geolimit') }}
@@ -272,7 +284,12 @@
let post = this.$root.pick(this.user.config, ['limit_geo'])
- post.greylist_enabled = $('#greylist_enabled').prop('checked') ? 1 : 0
+ const checklist = ['greylist_enabled', 'guam_enabled']
+ checklist.forEach(name => {
+ if ($('#' + name).length) {
+ post[name] = $('#' + name).prop('checked') ? 1 : 0
+ }
+ })
axios.post('/api/v4/users/' + this.user_id + '/config', post)
.then(response => {
diff --git a/src/tests/Browser/Admin/UserTest.php b/src/tests/Browser/Admin/UserTest.php
--- a/src/tests/Browser/Admin/UserTest.php
+++ b/src/tests/Browser/Admin/UserTest.php
@@ -87,6 +87,7 @@
$this->browse(function (Browser $browser) {
$jack = $this->getTestUser('jack@kolab.org');
$jack->setSetting('limit_geo', null);
+ $jack->setSetting('guam_enabled', null);
$page = new UserPage($jack->id);
@@ -191,11 +192,13 @@
$browser->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
->whenAvailable('@user-settings form', function (Browser $browser) {
- $browser->assertElementsCount('.row', 2)
+ $browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:first-child label', 'Greylisting')
->assertSeeIn('.row:first-child .text-success', 'enabled')
- ->assertSeeIn('.row:nth-child(2) label', 'Geo-lockin')
- ->assertSeeIn('.row:nth-child(2) #limit_geo', 'No restrictions')
+ ->assertSeeIn('.row:nth-child(2) label', 'IMAP proxy')
+ ->assertSeeIn('.row:nth-child(2) .text-danger', 'disabled')
+ ->assertSeeIn('.row:nth-child(3) label', 'Geo-lockin')
+ ->assertSeeIn('.row:nth-child(3) #limit_geo', 'No restrictions')
->assertMissing('#limit_geo + button');
});
});
@@ -465,7 +468,7 @@
$browser->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
->whenAvailable('@user-settings form', function (Browser $browser) {
- $browser->assertElementsCount('.row', 2)
+ $browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:first-child label', 'Greylisting')
->assertSeeIn('.row:first-child .text-danger', 'disabled');
});
@@ -593,8 +596,8 @@
$browser->visit(new UserPage($user->id))
->click('@nav #tab-settings')
->whenAvailable('@user-settings form', function (Browser $browser) {
- $browser->assertSeeIn('.row:nth-child(2) label', 'Geo-lockin')
- ->assertSeeIn('.row:nth-child(2) #limit_geo', 'Poland, Germany')
+ $browser->assertSeeIn('.row:nth-child(3) label', 'Geo-lockin')
+ ->assertSeeIn('.row:nth-child(3) #limit_geo', 'Poland, Germany')
->assertSeeIn('#limit_geo + button', 'Reset')
->click('#limit_geo + button');
})
diff --git a/src/tests/Browser/UsersTest.php b/src/tests/Browser/UsersTest.php
--- a/src/tests/Browser/UsersTest.php
+++ b/src/tests/Browser/UsersTest.php
@@ -27,6 +27,7 @@
'first_name' => 'John',
'last_name' => 'Doe',
'organization' => 'Kolab Developers',
+ 'limit_geo' => null,
];
/**
@@ -362,6 +363,7 @@
{
$john = $this->getTestUser('john@kolab.org');
$john->setSetting('greylist_enabled', null);
+ $john->setSetting('guam_enabled', null);
$john->setSetting('limit_geo', null);
$this->browse(function (Browser $browser) use ($john) {
@@ -373,7 +375,7 @@
->click('@nav #tab-settings')
->with('#settings form', function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting')
- ->assertMissing('div.row:nth-child(2)') // geo-lockin setting is hidden
+ ->assertMissing('div.row:nth-child(2)') // guam and geo-lockin settings are hidden
->click('div.row:nth-child(1) input[type=checkbox]:checked')
->click('button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.');
@@ -390,26 +392,32 @@
->click('@nav #tab-settings')
->with('#settings form', function (Browser $browser) use ($john) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting')
- ->assertSeeIn('div.row:nth-child(2) label', 'Geo-lockin')
+ ->assertSeeIn('div.row:nth-child(2) label', 'IMAP proxy')
+ ->assertNotChecked('div.row:nth-child(2) input')
+ ->assertSeeIn('div.row:nth-child(3) label', 'Geo-lockin')
->with(new CountrySelect('#limit_geo'), function ($browser) {
$browser->assertCountries([])
->setCountries(['DE', 'PL'])
->assertCountries(['DE', 'PL']);
})
+ ->click('div.row:nth-child(2) input')
->click('button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.');
$this->assertSame('["DE","PL"]', $john->getSetting('limit_geo'));
+ $this->assertSame('true', $john->getSetting('guam_enabled'));
$browser
->with(new CountrySelect('#limit_geo'), function ($browser) {
$browser->setCountries([])
->assertCountries([]);
})
+ ->click('div.row:nth-child(2) input')
->click('button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.');
$this->assertSame(null, $john->getSetting('limit_geo'));
+ $this->assertSame(null, $john->getSetting('guam_enabled'));
});
});
}
diff --git a/src/tests/Feature/Controller/NGINXTest.php b/src/tests/Feature/Controller/NGINXTest.php
--- a/src/tests/Feature/Controller/NGINXTest.php
+++ b/src/tests/Feature/Controller/NGINXTest.php
@@ -18,7 +18,7 @@
\App\AuthAttempt::where('user_id', $john->id)->delete();
$john->setSettings([
'limit_geo' => null,
- 'guam_enabled' => false,
+ 'guam_enabled' => null,
]);
\App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
@@ -35,7 +35,7 @@
\App\AuthAttempt::where('user_id', $john->id)->delete();
$john->setSettings([
'limit_geo' => null,
- 'guam_enabled' => false,
+ 'guam_enabled' => null,
]);
\App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
@@ -131,7 +131,7 @@
// Guam
- $john->setSettings(['guam_enabled' => true]);
+ $john->setSettings(['guam_enabled' => 'true']);
$response = $this->withHeaders($headers)->get("api/webhooks/nginx");
$response->assertStatus(200);
diff --git a/src/tests/Feature/Controller/UsersTest.php b/src/tests/Feature/Controller/UsersTest.php
--- a/src/tests/Feature/Controller/UsersTest.php
+++ b/src/tests/Feature/Controller/UsersTest.php
@@ -45,6 +45,7 @@
$wallet->discount()->dissociate();
$wallet->settings()->whereIn('key', ['mollie_id', 'stripe_id'])->delete();
$wallet->save();
+ $user->settings()->whereIn('key', ['greylist_enabled', 'guam_enabled'])->delete();
$user->status |= User::STATUS_IMAP_READY;
$user->save();
}
@@ -75,7 +76,7 @@
$wallet->discount()->dissociate();
$wallet->settings()->whereIn('key', ['mollie_id', 'stripe_id'])->delete();
$wallet->save();
- $user->settings()->whereIn('key', ['greylist_enabled'])->delete();
+ $user->settings()->whereIn('key', ['greylist_enabled', 'guam_enabled'])->delete();
$user->status |= User::STATUS_IMAP_READY;
$user->save();
@@ -297,6 +298,7 @@
$this->assertTrue(is_array($json['statusInfo']));
$this->assertTrue(is_array($json['settings']));
$this->assertTrue($json['config']['greylist_enabled']);
+ $this->assertFalse($json['config']['guam_enabled']);
$this->assertSame([], $json['skus']);
$this->assertSame([], $json['aliases']);
// Values below are tested by Unit tests
@@ -647,6 +649,7 @@
$john = $this->getTestUser('john@kolab.org');
$john->setSetting('greylist_enabled', null);
+ $john->setSetting('guam_enabled', null);
$john->setSetting('password_policy', null);
$john->setSetting('max_password_age', null);
@@ -686,6 +689,7 @@
// Test some valid data
$post = [
'greylist_enabled' => 1,
+ 'guam_enabled' => 1,
'password_policy' => 'min:10,max:255,upper,lower,digit,special',
'max_password_age' => 6,
];
@@ -700,12 +704,13 @@
$this->assertSame('User settings updated successfully.', $json['message']);
$this->assertSame('true', $john->getSetting('greylist_enabled'));
+ $this->assertSame('true', $john->getSetting('guam_enabled'));
$this->assertSame('min:10,max:255,upper,lower,digit,special', $john->getSetting('password_policy'));
$this->assertSame('6', $john->getSetting('max_password_age'));
// Test some valid data, acting as another account controller
$ned = $this->getTestUser('ned@kolab.org');
- $post = ['greylist_enabled' => 0, 'password_policy' => 'min:10,max:255,upper,last:1'];
+ $post = ['greylist_enabled' => 0, 'guam_enabled' => 0, 'password_policy' => 'min:10,max:255,upper,last:1'];
$response = $this->actingAs($ned)->post("/api/v4/users/{$john->id}/config", $post);
$response->assertStatus(200);
@@ -716,6 +721,7 @@
$this->assertSame('User settings updated successfully.', $json['message']);
$this->assertSame('false', $john->fresh()->getSetting('greylist_enabled'));
+ $this->assertSame(null, $john->fresh()->getSetting('guam_enabled'));
$this->assertSame('min:10,max:255,upper,last:1', $john->fresh()->getSetting('password_policy'));
}
diff --git a/src/tests/Feature/UserTest.php b/src/tests/Feature/UserTest.php
--- a/src/tests/Feature/UserTest.php
+++ b/src/tests/Feature/UserTest.php
@@ -468,6 +468,7 @@
{
$user = $this->getTestUser('UserAccountA@UserAccount.com');
$user->setSetting('greylist_enabled', null);
+ $user->setSetting('guam_enabled', null);
$user->setSetting('password_policy', null);
$user->setSetting('max_password_age', null);
$user->setSetting('limit_geo', null);
@@ -487,6 +488,21 @@
$this->assertSame(true, $user->getConfig()['greylist_enabled']);
$this->assertSame('true', $user->getSetting('greylist_enabled'));
+ // guam_enabled
+ $this->assertSame(false, $user->getConfig()['guam_enabled']);
+
+ $result = $user->setConfig(['guam_enabled' => false]);
+
+ $this->assertSame([], $result);
+ $this->assertSame(false, $user->getConfig()['guam_enabled']);
+ $this->assertSame(null, $user->getSetting('guam_enabled'));
+
+ $result = $user->setConfig(['guam_enabled' => true]);
+
+ $this->assertSame([], $result);
+ $this->assertSame(true, $user->getConfig()['guam_enabled']);
+ $this->assertSame('true', $user->getSetting('guam_enabled'));
+
// max_apssword_age
$this->assertSame(null, $user->getConfig()['max_password_age']);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 12:37 PM (2 d, 3 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18824097
Default Alt Text
D3734.1775219832.diff (17 KB)
Attached To
Mode
D3734: Guam opt-in
Attached
Detach File
Event Timeline