@@ -259,3 +259,121 @@ Following is an example of enabling root_squash in a filesystem except within
259259 caps mds = "allow rw fsname=a root_squash, allow rw fsname=a path=/volumes"
260260 caps mon = "allow r fsname=a"
261261 caps osd = "allow rw tag cephfs data=a"
262+
263+ Updating Capabilities using ``fs authorize ``
264+ ============================================
265+ After Ceph's Reef version, ``fs authorize `` can not only be used to create a
266+ new client with caps for a CephFS but it can also be used to add new caps
267+ (for a another CephFS or another path in same FS) to an already existing
268+ client.
269+
270+ Let's say we run following and create a new client::
271+
272+ $ ceph fs authorize a client.x / rw
273+ [client.x]
274+ key = AQAOtSVk9WWtIhAAJ3gSpsjwfIQ0gQ6vfSx/0w==
275+ $ ceph auth get client.x
276+ [client.x]
277+ key = AQAOtSVk9WWtIhAAJ3gSpsjwfIQ0gQ6vfSx/0w==
278+ caps mds = "allow rw fsname=a"
279+ caps mon = "allow r fsname=a"
280+ caps osd = "allow rw tag cephfs data=a"
281+
282+ Previously, running ``fs authorize a client.x / rw `` a second time used to
283+ print an error message. But after Reef, it instead prints message that
284+ there's not update::
285+
286+ $ ./bin/ceph fs authorize a client.x / rw
287+ no update for caps of client.x
288+
289+ Adding New Caps Using ``fs authorize ``
290+ --------------------------------------
291+ Users can now add caps for another path in same CephFS::
292+
293+ $ ceph fs authorize a client.x /dir1 rw
294+ updated caps for client.x
295+ $ ceph auth get client.x
296+ [client.x]
297+ key = AQAOtSVk9WWtIhAAJ3gSpsjwfIQ0gQ6vfSx/0w==
298+ caps mds = "allow r fsname=a, allow rw fsname=a path=some/dir"
299+ caps mon = "allow r fsname=a"
300+ caps osd = "allow rw tag cephfs data=a"
301+
302+ And even add caps for another CephFS on Ceph cluster::
303+
304+ $ ceph fs authorize b client.x / rw
305+ updated caps for client.x
306+ $ ceph auth get client.x
307+ [client.x]
308+ key = AQD6tiVk0uJdARAABMaQuLRotxTi3Qdj47FkBA==
309+ caps mds = "allow rw fsname=a, allow rw fsname=b"
310+ caps mon = "allow r fsname=a, allow r fsname=b"
311+ caps osd = "allow rw tag cephfs data=a, allow rw tag cephfs data=b"
312+
313+ Changing rw permissions in caps
314+ -------------------------------
315+
316+ It's not possible to modify caps by running ``fs authorize `` except for the
317+ case when read/write permissions have to be changed. This so because the
318+ ``fs authorize `` becomes ambiguous. For example, user runs ``fs authorize
319+ cephfs1 /dir1 client.x rw `` to create a client and then runs ``fs authorize
320+ cephfs1 /dir2 client.x rw `` (notice ``/dir1 `` is changed to ``/dir2 ``).
321+ Running second command can be interpreted as changing ``/dir1 `` to ``/dir2 ``
322+ in current cap or can also be interpreted as authorizing the client with a
323+ new cap for path ``/dir2 ``. As seen in previous sections, second
324+ interpretation is chosen and therefore it's impossible to update a part of
325+ capability granted except rw permissions. Following is how read/write
326+ permissions for ``client.x `` (that was created above) can be changed::
327+
328+ $ ceph fs authorize a client.x / r
329+ [client.x]
330+ key = AQBBKjBkIFhBDBAA6q5PmDDWaZtYjd+jafeVUQ==
331+ $ ceph auth get client.x
332+ [client.x]
333+ key = AQBBKjBkIFhBDBAA6q5PmDDWaZtYjd+jafeVUQ==
334+ caps mds = "allow r fsname=a"
335+ caps mon = "allow r fsname=a"
336+ caps osd = "allow r tag cephfs data=a"
337+
338+ ``fs authorize `` never deducts any part of caps
339+ -----------------------------------------------
340+ It's not possible to remove caps issued to a client by running ``fs
341+ authorize `` again. For example, if a client cap has ``root_squash `` applied
342+ on a certain CephFS, running ``fs authorize `` again for the same CephFS but
343+ without ``root_squash `` will not lead to any update, the client caps will
344+ remain unchanged::
345+
346+ $ ceph fs authorize a client.x / rw root_squash
347+ [client.x]
348+ key = AQD61CVkcA1QCRAAd0XYqPbHvcc+lpUAuc6Vcw==
349+ $ ceph auth get client.x
350+ [client.x]
351+ key = AQD61CVkcA1QCRAAd0XYqPbHvcc+lpUAuc6Vcw==
352+ caps mds = "allow rw fsname=a root_squash"
353+ caps mon = "allow r fsname=a"
354+ caps osd = "allow rw tag cephfs data=a"
355+ $ ceph fs authorize a client.x / rw
356+ [client.x]
357+ key = AQD61CVkcA1QCRAAd0XYqPbHvcc+lpUAuc6Vcw==
358+ no update was performed for caps of client.x. caps of client.x remains unchanged.
359+
360+ And if a client already has a caps for FS name ``a `` and path ``dir1 ``,
361+ running ``fs authorize `` again for FS name ``a `` but path ``dir2 ``, instead
362+ of modifying the caps client already holds, a new cap for ``dir2 `` will be
363+ granted::
364+
365+ $ ceph fs authorize a client.x /dir1 rw
366+ $ ceph auth get client.x
367+ [client.x]
368+ key = AQC1tyVknMt+JxAAp0pVnbZGbSr/nJrmkMNKqA==
369+ caps mds = "allow rw fsname=a path=/dir1"
370+ caps mon = "allow r fsname=a"
371+ caps osd = "allow rw tag cephfs data=a"
372+ $ ceph fs authorize a client.x /dir2 rw
373+ updated caps for client.x
374+ $ ceph auth get client.x
375+ [client.x]
376+ key = AQC1tyVknMt+JxAAp0pVnbZGbSr/nJrmkMNKqA==
377+ caps mds = "allow rw fsname=a path=dir1, allow rw fsname=a path=dir2"
378+ caps mon = "allow r fsname=a"
379+ caps osd = "allow rw tag cephfs data=a"
0 commit comments