Skip to content

Commit 3b6bde2

Browse files
committed
update user docs
1 parent 6cc790c commit 3b6bde2

File tree

6 files changed

+123
-8
lines changed

6 files changed

+123
-8
lines changed

docs/.vitepress/config.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export default defineConfig({
2525
{ text: 'CLI Commands', link: '/commands' },
2626
{ text: 'Environment Variables', link: '/environment-variables' },
2727
{ text: 'Permission System', link: '/permission' },
28+
{ text: 'User Management', link: '/userman' },
29+
{ text: 'Virtual User', link: '/virtual-user' },
2830
{ text: 'Configure Single Directory', link: '/lfssdir' },
2931
{ text: 'WebDAV', link: '/webdav' },
3032
{ text: 'Development', link: '/Development' },

docs/lfssdir.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
# Configure Single Directory
33

4+
> Added in v0.14.0.
5+
46
You can configure the behavior of a single directory by placing a special file named `.lfssdir.json` in it.
57

68
The file should contain a JSON object with the following optional fields:

docs/permission.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@ There are different access levels for different users, which determine what oper
99
- <span class="perm">read</span>: only `GET` permission and listing directories.
1010
- <span class="perm">none</span>: no permissions.
1111

12+
:::info
13+
**directory** path ends with `/` and **file** does not end with `/`.
14+
:::
15+
1216
## User Roles
13-
There are two user roles in the system: Admin and Normal User ("users" are like "buckets" to some extent).
14-
A user have <span class="perm">all</span> permissions of the files and directories under its path (starting with `/<user>/`).
15-
Admins have <span class="perm">admin</span> permissions of all files and directories.
17+
There are three user roles in the system: Admin, Normal User, and Virtual User
18+
- A normal user have <span class="perm">all</span> permissions of the files and directories under its path (starting with `/<user>/`).
19+
- A virtual user doesn't have it's own path.
20+
- Admins have <span class="perm">admin</span> permissions of all files and directories.
21+
22+
:::tip **Users are like "buckets" or "access keys" to some extent**
23+
Normal users are like "buckets" that own files and directories.
24+
Virtual users are like "access keys" that have expiry time and limited access to some users' paths.
25+
:::
26+
27+
**Below sections only discuss normal users and admins. For virtual users, please refer to the [Virtual User](./virtual-user.md) document.**
28+
1629

17-
> **directory** path ends with `/` and **file** does not end with `/`.
1830

1931
### Ownership
2032
There are two types of ownership for files (terms used in permission checks):

docs/userman.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# User Management
2+
3+
All user management operations can be performed via the `lfss-user` command.
4+
Using `-h` or `--help` flag will show the help message with all available subcommands and options:
5+
```bash
6+
> lfss-user -h
7+
usage: lfss-user [-h] {add,add-virtual,delete,set,list,set-peer,set-expire} ...
8+
9+
positional arguments:
10+
{add,add-virtual,delete,set,list,set-peer,set-expire}
11+
add Add a new user
12+
add-virtual Add a virtual (hidden) user, username will be prefixed with '.v-'
13+
set Set user properties, refer to 'add' subcommand for details on each argument
14+
list List specified users, or detailed info with -l
15+
set-peer Set peer user relationship
16+
set-expire Set or clear user expire time
17+
```
18+
19+
Most of the commands are self-explanatory,
20+
and the details flags of each command can be found by using the `-h` flag after the subcommand.
21+
22+
**Below are some extra explanations for a few commands.**
23+
24+
## Check user details
25+
Besides listing all users,
26+
to check the details of the user(s), you can also use the `list` subcommand with the `-l/--long` flag,
27+
followed by one or more usernames. For example:
28+
```bash
29+
> lfss-user list -l alice
30+
User alice (id=20, admin=0, created at 2025-11-13 03:15:09, last active at 2025-11-13 03:15:09, storage=1.00G, permission=UNSET)
31+
- Credential: d9cf3312d1da59721fd28a5d3075c65b858a373d37e479c2defd6bfeee207677
32+
- Storage: 0B / 1.00G
33+
- Expire: never
34+
- Peers [READ]: bob, carol
35+
- Peers [WRITE]: dave
36+
```
37+
38+
## Delete user
39+
To delete a user, you can use the `delete` subcommand.
40+
```bash
41+
> lfss-user delete alice
42+
```
43+
44+
Note: there are a few clean up operations that need to be done when deleting a user,
45+
so the deletion process may take some time depending on the number of files owned by the user,
46+
and because this process is transactional, it may block the system for a short period.
47+
48+
Specifically, user deletion involves:
49+
- Remove user record from the database.
50+
- Remove all files under the user's path.
51+
- Transfer ownership of all files owned by the user under other users' paths to the path owner.
52+
53+
If any of the above steps fail
54+
(for example, the path owner has insufficient storage space to take over the ownership),
55+
the deletion process will be rolled back to ensure data consistency.

docs/virtual-user.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Virtual User
2+
3+
> Added in v0.16.0.
4+
5+
Virtual user is a user without its own path.
6+
It can only access files and directories under other users' paths according to the peer user settings,
7+
and anybody want to access virtual user's path will get permission denied.
8+
9+
In addition, virtual users is preferred to have an expiry time, after which they can no longer access the system.
10+
This makes virtual users essentially "access keys" to some users' paths.
11+
12+
The virtual user always have a name starting with `.v-`,
13+
a typical virtual user name looks like `.v-{tag}-{id}`.
14+
The tag is used to identify the purpose of the virtual user, and the id is a unique random string.
15+
16+
To create a virtual user, you can use either the CLI command or the admin API. For example:
17+
18+
```bash
19+
lfss-user add-virtual
20+
--tag tmpuser
21+
--expire 1d12h
22+
--max-storage 100M
23+
--peers "read:alice,bob;write:carol"
24+
```
25+
26+
```python
27+
Client().add_virtual_user(
28+
tag="tmpuser",
29+
expire="1d12h",
30+
max_storage="100M",
31+
peers={
32+
AccessLevel.READ: ["alice", "bob"],
33+
AccessLevel.WRITE: ["carol"]
34+
}
35+
)
36+
```
37+
38+
To modify the expiry time of a virtual user, you can use the CLI command. For example:
39+
```bash
40+
lfss-user set-expire .v-tmpuser-VwFdjKpiqm4 2d1h10s
41+
```
42+
43+
The management of virtual users is exactly the same as normal users. *e.g.*, via `lfss-user` command or admin API.
44+

lfss/cli/user.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
async def _main():
1212
parser = argparse.ArgumentParser()
1313
sp = parser.add_subparsers(dest='subparser_name', required=True)
14-
sp_add = sp.add_parser('add')
14+
sp_add = sp.add_parser('add', help="Add a new user")
1515
sp_add.add_argument('username', type=str)
1616
sp_add.add_argument('password', nargs='?', type=str, default=None)
1717
sp_add.add_argument('--admin', action='store_true', help='Set user as admin')
@@ -40,17 +40,17 @@ def parse_bool(s):
4040
sp_set.add_argument('--permission', type=parse_permission, default=None)
4141
sp_set.add_argument('--max-storage', type=parse_storage_size, default=None)
4242

43-
sp_list = sp.add_parser('list')
43+
sp_list = sp.add_parser('list', help="List specified users, or detailed info with -l")
4444
sp_list.add_argument("username", nargs='*', type=str, default=None)
4545
sp_list.add_argument("-l", "--long", action="store_true", help="Show detailed information, including credential and peer users")
4646
sp_list.add_argument("--hidden", action="store_true", help="Include hidden users (virtual users) in the listing")
4747

48-
sp_peer = sp.add_parser('set-peer')
48+
sp_peer = sp.add_parser('set-peer', help="Set peer user relationship")
4949
sp_peer.add_argument('src_username', type=str)
5050
sp_peer.add_argument('dst_username', type=str)
5151
sp_peer.add_argument('--level', type=parse_access_level, default=AccessLevel.READ, help="Access level")
5252

53-
sp_expire = sp.add_parser('set-expire')
53+
sp_expire = sp.add_parser('set-expire', help="Set or clear user expire time")
5454
sp_expire.add_argument('username', type=str)
5555
sp_expire.add_argument('expire_time', type=str, nargs='?', default=None, help="Expire time in seconds or a string like '1d2h3m4s'. If not provided, the user will never expire.")
5656

0 commit comments

Comments
 (0)