Skip to content

Commit f48d1b2

Browse files
authored
Merge branch 'master' into dependabot/pip/master/idna-3.19
2 parents 661bf23 + d85263a commit f48d1b2

10 files changed

Lines changed: 443 additions & 260 deletions

File tree

‎admin_manual/ai/app_assistant.rst‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,33 @@ To enable/disable the text-to-image smart picker for all the users.
191191
192192
To enable/disable the speech-to-text smart picker for all the users.
193193

194+
5. Data folder
195+
196+
.. code-block::
197+
198+
occ config:app:set assistant default_data_folder --value="Assistant" --type=string
199+
200+
The assistant stores the content it generates, such as generated images and speech-to-text
201+
output, in a folder in the files of each user. This sets the name that folder is given when
202+
it is created. It defaults to ``Assistant``, and is also editable in the Assistant admin
203+
settings.
204+
205+
Users can choose their own name in their personal Assistant settings, which is stored per
206+
user and takes precedence over the server-wide default:
207+
208+
.. code-block::
209+
210+
occ user:setting $USER_ID assistant data_folder "Assistant"
211+
212+
Two things to keep in mind:
213+
214+
* Changing either value does not rename or move a folder that already exists. It only
215+
affects the name used the next time a folder has to be created, so existing generated
216+
content stays where it is.
217+
* A user who already has a folder under the built-in name ``Assistant``, from before a
218+
default was set, keeps using it. This avoids starting a second folder for them and
219+
leaving their earlier output behind.
220+
194221
Task processing
195222
~~~~~~~~~~~~~~~
196223

‎conf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# via detect-versions.php so these values are always current without manual updates.
6262
# Fallbacks here are used for local builds only.
6363
version_start = int(os.environ.get('DOCS_VERSION_START', 32))
64-
version_stable = int(os.environ.get('DOCS_VERSION_STABLE', 34)) # CHANGING IT MUST RESULT IN A CHANGE OF THE SYMLINK ON THE LIVE SERVER
64+
version_stable = int(os.environ.get('DOCS_VERSION_STABLE', 35)) # CHANGING IT MUST RESULT IN A CHANGE OF THE SYMLINK ON THE LIVE SERVER
6565
# In CI: DOCS_DISPLAY_VERSION is injected by sphinxbuild.yml.
6666
# Fallback: PDF/ePub builds use release (DOCS_RELEASE); local master builds use version_stable+1.
6767
display_version = os.environ.get('DOCS_DISPLAY_VERSION') or (

‎developer_manual/basics/setting.rst‎

Lines changed: 168 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Settings
44

55
.. sectionauthor:: Carl Schwan <carl@carlschwan.eu>
66

7+
Creating an admin section
8+
-------------------------
9+
710
Each Nextcloud application can provide both personal and admin settings. For this
811
you will need to create a section implementing `IIconSection`. This section will be
912
used in the setting sidebar to create a new entry.
@@ -45,9 +48,8 @@ In our case we will create an admin section class in **<myapp>/lib/Sections/Note
4548
}
4649
}
4750
48-
49-
The next step is to fill the new admin section with am admin setting. For that, we create a new class
50-
in *<myapp>/lib/Settings/NotesAdmin.php**.
51+
The next step is to fill the new admin section with an admin setting. For that,
52+
we create a new class in ``<myapp>/lib/Settings/NotesAdmin.php``.
5153

5254
.. code-block:: php
5355
@@ -109,11 +111,29 @@ The last missing part is to register both classes inside **<myapp>/appinfo/info.
109111
To register personal sections and settings class use `<personal-section>` and
110112
`<personal>` instead.
111113

112-
Additionally since Nextcloud 23, groups can be granted authorization to access individual
113-
admin settings (`see admin docs <https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/admin_delegation_configuration.html>`_).
114-
This is a feature that needs to be enabled for each admin setting class.
115-
To do so, the setting class needs to implement `IDelegatedSettings` instead of `ISettings`
116-
and implement two additional methods.
114+
Delegated administration
115+
------------------------
116+
117+
.. versionadded:: 23
118+
119+
Nextcloud has built-in functionality which permits `administrators to delegate authority
120+
<https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/admin_delegation_configuration.html>`_
121+
to others without granting them full administration privileges (and without making them a
122+
member of the ``admin`` group).
123+
124+
Specific groups can be granted authorization to access individual admin settings. This is a
125+
feature that needs to be enabled for each admin setting class. To do so, the setting class
126+
needs to implement ``IDelegatedSettings`` instead of ``ISettings`` and implement two additional
127+
methods.
128+
129+
Authorizing app-config keys
130+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
131+
132+
The values returned by ``getAuthorizedAppConfig()`` define which app-config keys delegated
133+
administrators may modify. Use exact key names whenever possible. Regular expressions are
134+
supported for dynamic key names, but should match the complete key using ``^`` and ``$``.
135+
Avoid unanchored expressions such as ``/notes_.*/``, which can match a key that merely
136+
contains the intended prefix.
117137

118138
.. code-block:: php
119139
@@ -137,19 +157,138 @@ and implement two additional methods.
137157
138158
public function getAuthorizedAppConfig(): array {
139159
return [
140-
// Allow a list of regex that the user can modify with this setting.
141-
'notes' => ['/notes_.*/', '/my_notes_setting/'],
160+
// Simplest: authorize one exact key from this app.
161+
'notes' => [
162+
'my_notes_setting',
163+
],
142164
];
143165
}
144166
}
145167
146-
Additionally, if your setting class needs to fetch data or send data to some admin-only
147-
controllers, you will need to mark the methods in the controller as accessible by the
148-
setting with attribute.
168+
Using the application ID
169+
~~~~~~~~~~~~~~~~~~~~~~~~
149170

150-
.. note::
171+
The app name can be referenced through ``Application::APP_ID``. This avoids duplicating
172+
the app ID as a string:
173+
174+
.. code-block:: php
175+
176+
use OCA\NotesTutorial\AppInfo\Application;
177+
178+
public function getAuthorizedAppConfig(): array {
179+
return [
180+
// Multiple keys: authorize several exact keys in this app.
181+
Application::APP_ID => [
182+
'my_notes_setting',
183+
'another_notes_setting',
184+
],
185+
];
186+
}
187+
188+
Authorizing dynamic key names
189+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190+
191+
For a family of dynamically named keys, use an anchored regular expression that is as
192+
restrictive as possible:
193+
194+
.. code-block:: php
195+
196+
public function getAuthorizedAppConfig(): array {
197+
return [
198+
// Authorize keys such as "notes_feature_a" and "notes_feature_b",
199+
// but not "custom_notes_feature_a".
200+
Application::APP_ID => [
201+
'/^notes_[a-z0-9_]+$/',
202+
],
203+
];
204+
}
205+
206+
Escaping dynamic regular expressions
207+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208+
209+
When a regular expression is built from a variable or a constant, escape the inserted
210+
value with ``preg_quote()``:
211+
212+
.. code-block:: php
213+
214+
$prefix = preg_quote('notes_', '/');
215+
216+
return [
217+
Application::APP_ID => [
218+
"/^{$prefix}[a-z0-9_]+$/",
219+
],
220+
];
221+
222+
Using configuration constants
223+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
224+
225+
For stable, declared configuration keys, prefer dedicated constants or constants from an
226+
app's ``ConfigLexicon`` class. This keeps the delegated authorization list synchronized
227+
with the app's configuration definitions.
228+
229+
For example, ``<myapp>/lib/ConfigLexicon.php`` might contain:
151230

152-
The attribute is only available in Nextcloud 27 or later. In older versions, the ``@AuthorizedAdminSetting(settings=OCA\NotesTutorial\Settings\NotesAdmin)`` annotation can be used.
231+
.. code-block:: php
232+
233+
<?php
234+
namespace OCA\NotesTutorial;
235+
236+
class ConfigLexicon {
237+
// For PHP versions before 8.3, omit the "string" type.
238+
public const string MY_SETTING = 'my_notes_setting';
239+
public const string ANOTHER_SETTING = 'another_notes_setting';
240+
}
241+
242+
Which can then reference:
243+
244+
.. code-block:: php
245+
246+
use OCA\NotesTutorial\AppInfo\Application;
247+
use OCA\NotesTutorial\ConfigLexicon;
248+
249+
public function getAuthorizedAppConfig(): array {
250+
return [
251+
// Constants: Preferred for stable, declared configuration keys.
252+
Application::APP_ID => [
253+
ConfigLexicon::MY_SETTING,
254+
ConfigLexicon::ANOTHER_SETTING,
255+
],
256+
];
257+
}
258+
259+
Authorizing keys from multiple apps
260+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261+
262+
If a setting intentionally authorizes configuration keys from more than one app, return
263+
one entry for each app. Prefer the corresponding app's ``Application::APP_ID`` constant
264+
when it is available:
265+
266+
.. code-block:: php
267+
268+
use OCA\AnotherApp\AppInfo\Application as AnotherAppApplication;
269+
270+
public function getAuthorizedAppConfig(): array {
271+
return [
272+
Application::APP_ID => [
273+
ConfigLexicon::MY_SETTING,
274+
],
275+
AnotherAppApplication::APP_ID => [
276+
// Prefer AnotherApp's ConfigLexicon constant when available.
277+
'another_setting',
278+
],
279+
];
280+
}
281+
282+
Do not use ``/.*/`` unless the setting intentionally grants delegated administrators
283+
access to every key belonging to the app. Do not use a regular expression for a fixed key:
284+
return the literal key instead.
285+
286+
Authorizing admin-only controllers
287+
----------------------------------
288+
289+
The ``getAuthorizedAppConfig()`` method controls app-config writes. It does not grant
290+
access to arbitrary controller endpoints. If your setting class needs to call admin-only
291+
controller methods, mark those methods with the ``AuthorizedAdminSetting`` attribute.
153292

154293
.. code-block:: php
155294
:emphasize-lines: 8
@@ -168,14 +307,17 @@ setting with attribute.
168307
...
169308
}
170309
171-
172-
If you have several ``IDelegatedSettings`` classes that are needed for a function, add multiple attributes and separate them with semicolons.
173-
174310
.. note::
175311

176-
If you use the deprecated annotation specify the classes separated by semicolons:
312+
The attribute is only available in Nextcloud 27 or later. In older versions, the
313+
``@AuthorizedAdminSetting(settings=OCA\NotesTutorial\Settings\NotesAdmin)`` annotation
314+
must be used instead.
177315

178-
``@AuthorizedAdminSetting(settings=OCA\NotesTutorial\Settings\NotesAdmin;OCA\NotesTutorial\Settings\NotesSubAdmin)``
316+
Authorizing multiple delegated settings
317+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318+
319+
If you have several ``IDelegatedSettings`` classes that are needed for a function, add multiple
320+
attributes:
179321

180322
.. code-block:: php
181323
:emphasize-lines: 8-9
@@ -194,3 +336,9 @@ If you have several ``IDelegatedSettings`` classes that are needed for a functio
194336
}
195337
...
196338
}
339+
340+
.. note::
341+
342+
If you must use the deprecated annotation, specify the classes separated by semicolons:
343+
344+
``@AuthorizedAdminSetting(settings=OCA\NotesTutorial\Settings\NotesAdmin;OCA\NotesTutorial\Settings\NotesSubAdmin)``

0 commit comments

Comments
 (0)