Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/bruteforcesettings-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/bruteforcesettings-main.js.map

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/Settings/IPWhitelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace OCA\BruteForceSettings\Settings;

use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\IRequest;
use OCP\Security\Bruteforce\IThrottler;
Expand All @@ -24,13 +25,15 @@ public function __construct(
protected IRequest $request,
protected IInitialState $initialState,
protected IThrottler $throttler,
protected IAppConfig $appConfig,
) {
}

public function getForm(): TemplateResponse {
$this->initialState->provideInitialState('remote-address', $this->request->getRemoteAddress());
$this->initialState->provideInitialState('bypass-listed', $this->throttler->isBypassListed($this->request->getRemoteAddress()));
$this->initialState->provideInitialState('delay', $this->throttler->getDelay($this->request->getRemoteAddress()));
$this->initialState->provideInitialState('apply_allowlist_to_ratelimit', $this->appConfig->getAppValueBool('apply_allowlist_to_ratelimit'));

return new TemplateResponse('bruteforcesettings', 'ipwhitelist');
}
Expand Down
22 changes: 22 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
</tbody>
</table>

<NcCheckboxRadioSwitch :model-value="isApplyAllowListToRateLimitEnabled"
:disabled="loading"
type="switch"
@update:model-value="saveApplyAllowListToRateLimit">
{{ t('spreed', 'Apply whitelist to rate limit') }}
</NcCheckboxRadioSwitch>

<h3>{{ t('bruteforcesettings', 'Add a new whitelist') }}</h3>
<div class="whitelist__form">
<NcInputField id="ip"
Expand Down Expand Up @@ -71,6 +78,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
import NcInputField from '@nextcloud/vue/dist/Components/NcInputField.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'

import PlusIcon from 'vue-material-design-icons/Plus.vue'

Expand All @@ -84,6 +92,7 @@ export default {
NcButton,
NcNoteCard,
NcSettingsSection,
NcCheckboxRadioSwitch,
NcInputField,
PlusIcon,
},
Expand All @@ -97,6 +106,8 @@ export default {
remoteAddress: '',
delay: 0,
isBypassListed: false,
isApplyAllowListToRateLimitEnabled: false,
loading: false,
}
},

Expand Down Expand Up @@ -128,6 +139,7 @@ export default {
this.remoteAddress = loadState('bruteforcesettings', 'remote-address', '127.0.0.1')
this.isBypassListed = loadState('bruteforcesettings', 'bypass-listed', false)
this.delay = loadState('bruteforcesettings', 'delay', 0)
this.isApplyAllowListToRateLimitEnabled = loadState('bruteforcesettings', 'apply_allowlist_to_ratelimit', false)

axios.get(generateUrl('apps/bruteforcesettings/ipwhitelist'))
.then((response) => {
Expand Down Expand Up @@ -157,6 +169,16 @@ export default {
showError(t('bruteforcesettings', 'There was an error adding the IP to the whitelist.'))
}
},

saveApplyAllowListToRateLimit(value) {
this.loading = true
OCP.AppConfig.setValue('bruteforcesettings', 'apply_allowlist_to_ratelimit', value ? 1 : 0, {
success: () => {
this.loading = false
this.isApplyAllowListToRateLimitEnabled = value
},
})
},
},
}
</script>
Expand Down
Loading