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
2 changes: 1 addition & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function register(IRegistrationContext $context): void {
$context->registerService(DavPlugin::class, fn (ContainerInterface $c) => new DavPlugin(
$c->get(ISession::class),
$c->get(IAppConfig::class),
$_SERVER,
$_ENV,
$c->get(SAMLSettings::class),
$c->get(SessionService::class),
));
Expand Down
15 changes: 14 additions & 1 deletion lib/Db/ConfigurationsMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,31 @@

use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\QBMapper;
use OCP\AppFramework\Services\IAppConfig;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;

/**
* @template-extends QBMapper<ConfigurationsEntity>
*/
class ConfigurationsMapper extends QBMapper {
public function __construct(IDBConnection $db) {
public function __construct(
IDBConnection $db,
private readonly IAppConfig $appConfig,
) {
parent::__construct($db, 'user_saml_configurations', ConfigurationsEntity::class);
}

/**
* @throws \InvalidArgumentException
*/
public function set(int $id, array $configuration): void {
if (
$this->appConfig->getAppValueString('type') === 'environment-variable'
&& isset($configuration['general-uid_mapping'])
&& str_starts_with($configuration['general-uid_mapping'], 'HTTP_')) {
throw new \InvalidArgumentException('Environment var starting with HTTP_ are not allowed as HTTP headers are saved in these environment variables');
}
$entity = new ConfigurationsEntity();
$entity->setId($id);
$entity->importConfiguration($configuration);
Expand Down
27 changes: 23 additions & 4 deletions src/components/ProviderGeneralSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<template v-if="attribute.type === 'checkbox' && !attribute.global && attribute.provider_type === '' || attribute.provider_type === type">
<NcCheckboxRadioSwitch
:modelValue="modelValue[key] === '1'"
@update:modelValue="(val: boolean) => onChange(key, val ? '1' : '0')">
@update:modelValue="(val: boolean) => update(key, val ? '1' : '0')">
{{ attribute.text }}
</NcCheckboxRadioSwitch>
<NcNoteCard v-if="key === 'is_saml_request_using_post'" type="warning">
Expand All @@ -20,7 +20,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
:label="attribute.text"
:modelValue="modelValue[key] ?? ''"
:required="attribute.required"
@update:modelValue="(val: string|number) => type === 'env' ? onChangeDebounced(key, val + '') : onChange(key, val + '')" />
:error="isError(key)"
:helperText="isError(key) ? t('user_saml', 'Environment var starting with HTTP_ are not allowed as HTTP headers are saved in these environment variables') : undefined"
@update:modelValue="(val: string|number) => update(key, val + '')" />
</template>
</template>

Expand Down Expand Up @@ -49,7 +51,9 @@ const emit = defineEmits<{
* @param value The new value
*/
function onChange(key: string, value: string): void {
emit('update:modelValue', { ...props.modelValue, [key]: value })
if (isError(key)) {
return
}
emit('fieldChange', key, value)
}

Expand All @@ -62,10 +66,25 @@ const debounceTimers = ref<Record<string, ReturnType<typeof setTimeout>>>({})
* @param value The new value
*/
function onChangeDebounced(key: string, value: string): void {
emit('update:modelValue', { ...props.modelValue, [key]: value })
clearTimeout(debounceTimers.value[key])
debounceTimers.value[key] = setTimeout(() => {
if (isError(key)) {
return
}
emit('fieldChange', key, value)
}, 500)
}

function update(key: string, value: string): void {
emit('update:modelValue', { ...props.modelValue, [key]: value })
if (props.type === 'env') {
onChangeDebounced(key, value)
} else {
onChange(key, value)
}
}

function isError(key: string): boolean {
return key === 'uid_mapping' && props.type === 'env' && (props.modelValue[key] ?? '').startsWith('HTTP_')
}
</script>
Loading