diff --git a/TODO.txt b/TODO.txt index ea73787..5c5e89f 100644 --- a/TODO.txt +++ b/TODO.txt @@ -61,7 +61,7 @@ Milestone: v0.4.0 [ ] Finish RouteAliasDirectory [ ] Add "id" objects when putting aliases [ ] Delete from "id" when deleting alias - [ ] Add alias admin privilege to allow admins to manage aliases + [x] Add alias admin privilege to allow admins to manage aliases Milestone: v0.5.0 ----------------- diff --git a/man/man7/telodendria-admin.7 b/man/man7/telodendria-admin.7 index ce2f19d..2fd0964 100644 --- a/man/man7/telodendria-admin.7 +++ b/man/man7/telodendria-admin.7 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: April 20 2023 $ +.Dd $Mdocdate: August 9 2023 $ .Dt TELODENDRIA-ADMIN 7 .Os Telodendria Project .Sh NAME @@ -32,6 +32,10 @@ Allows a user to modify the Telodendria server daemon's configuration. .It Dv GRANT_PRIVILEGES Allows a user to modify his or her own privileges or the privileges of other local users. +.It Dv ALIAS +Allows a user to modify room aliases created by other users. By default, users +can only manage their own room aliases, but an administrator may wish to take +over an alias or remove an offensive alias. .It Dv PROC_CONTROL Allows a user to get statistics on the running process, as well as shutdown and restart the Telodendria daemon itself. Typically this will pair well with diff --git a/src/Routes/RouteAliasDirectory.c b/src/Routes/RouteAliasDirectory.c index cb4cea6..4e960c9 100644 --- a/src/Routes/RouteAliasDirectory.c +++ b/src/Routes/RouteAliasDirectory.c @@ -135,7 +135,7 @@ ROUTE_IMPL(RouteAliasDirectory, path, argp) goto finish; } - if (!StrEquals(UserGetName(user), JsonValueAsString(JsonGet(aliases, 3, "alias", alias, "createdBy")))) + if (!(UserGetPrivileges(user) & USER_ALIAS) && !StrEquals(UserGetName(user), JsonValueAsString(JsonGet(aliases, 3, "alias", alias, "createdBy")))) { HttpResponseStatus(args->context, HTTP_UNAUTHORIZED); response = MatrixErrorCreate(M_UNAUTHORIZED, NULL); diff --git a/src/User.c b/src/User.c index 63ff8c6..ce022e0 100644 --- a/src/User.c +++ b/src/User.c @@ -802,6 +802,10 @@ UserDecodePrivilege(const char *p) { return USER_PROC_CONTROL; } + else if (StrEquals(p, "ALIAS")) + { + return USER_ALIAS; + } else { return USER_NONE; @@ -835,6 +839,7 @@ UserEncodePrivileges(int privileges) A(USER_CONFIG, "CONFIG"); A(USER_GRANT_PRIVILEGES, "GRANT_PRIVILEGES"); A(USER_PROC_CONTROL, "PROC_CONTROL"); + A(USER_ALIAS, "ALIAS"); #undef A diff --git a/src/include/User.h b/src/include/User.h index 9ff8c00..b813c33 100644 --- a/src/include/User.h +++ b/src/include/User.h @@ -61,7 +61,8 @@ typedef enum UserPrivileges USER_CONFIG = (1 << 2), USER_GRANT_PRIVILEGES = (1 << 3), USER_PROC_CONTROL = (1 << 4), - USER_ALL = ((1 << 5) - 1) + USER_ALIAS = (1 << 5), + USER_ALL = ((1 << 6) - 1) } UserPrivileges; /**