Skip to content

Commit 407e621

Browse files
authored
Fix permissions on project component edits (#5526)
1 parent 83ea7f6 commit 407e621

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

apps/labrinth/fixtures/labrinth-seed-data-202508052143.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,10 +1112,13 @@ COPY public.loaders_project_types_games (loader_id, project_type_id, game_id) FR
11121112

11131113
COPY public.users (id, github_id, username, email, avatar_url, bio, created, role, badges, balance, discord_id, gitlab_id, google_id, steam_id, microsoft_id, password, email_verified, totp_secret, paypal_country, paypal_email, paypal_id, venmo_handle, stripe_customer_id, raw_avatar_url, allow_friend_requests) FROM stdin;
11141114
103587649610509 \N Default admin user admin@modrinth.invalid https://avatars.githubusercontent.com/u/106493074 $ chmod 777 labrinth 2020-07-18 16:03:00.000000+00 admin 0 0.00000000000000000000 \N \N \N \N \N $argon2i$v=19$m=4096,t=3,p=1$c2FsdEl0V2l0aFNhbHQ$xTGvQNICqetaNA0Wu1GwFmYhQjAreRcjBz6ornhaFXA t \N \N \N \N \N \N https://avatars.githubusercontent.com/u/106493074 t
1115+
905016946785301 \N Regular user user@modrinth.invalid https://avatars.githubusercontent.com/u/106493074 $ chmod 744 labrinth 2020-07-18 16:03:00.000000+00 developer 0 0.00000000000000000000 \N \N \N \N \N $argon2i$v=19$m=4096,t=3,p=1$c2FsdEl0V2l0aFNhbHQ$xTGvQNICqetaNA0Wu1GwFmYhQjAreRcjBz6ornhaFXA t \N \N \N \N \N \N https://avatars.githubusercontent.com/u/106493074 t
11151116
\.
11161117

11171118
INSERT INTO sessions (id, session, user_id, created, last_login, expires, refresh_expires, city, country, ip, os, platform, user_agent)
1118-
VALUES (93083445641246, 'mra_admin', 103587649610509, '2025-10-20 14:58:53.128901+00', '2025-10-20 14:58:53.128901+00', '2030-11-03 14:58:53.128901+00', '2030-12-19 14:58:53.128901+00', '', '', '127.0.0.1', 'Linux', 'Chrome', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36');
1119+
VALUES
1120+
(93083445641246, 'mra_admin', 103587649610509, '2025-10-20 14:58:53.128901+00', '2025-10-20 14:58:53.128901+00', '2030-11-03 14:58:53.128901+00', '2030-12-19 14:58:53.128901+00', '', '', '127.0.0.1', 'Linux', 'Chrome', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36'),
1121+
(64214654438039, 'mra_user', 905016946785301, '2025-10-20 14:58:53.128901+00', '2025-10-20 14:58:53.128901+00', '2030-11-03 14:58:53.128901+00', '2030-12-19 14:58:53.128901+00', '', '', '127.0.0.1', 'Linux', 'Chrome', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36');
11191122

11201123
INSERT INTO payouts_values (user_id, amount, created, date_available)
11211124
VALUES (103587649610509, 1000.00000000000000000000, '2025-10-23 00:00:00+00', '2025-10-23 00:00:00+00');

apps/labrinth/src/routes/v3/projects.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,12 +998,20 @@ pub async fn project_edit_internal(
998998
_project_id: DBProjectId,
999999
edit: Option<Option<E>>,
10001000
mut component: &mut Option<E::Component>,
1001+
perms: ProjectPermissions,
10011002
) -> Result<(), ApiError> {
10021003
let Some(edit) = edit else {
10031004
// component is not specified in the input JSON - leave alone
10041005
return Ok(());
10051006
};
10061007

1008+
if !perms.contains(ProjectPermissions::EDIT_DETAILS) {
1009+
return Err(ApiError::CustomAuthentication(
1010+
"You do not have the permissions to edit the components of this project!"
1011+
.to_string(),
1012+
));
1013+
}
1014+
10071015
match (&mut component, edit) {
10081016
(None, None) => {}
10091017
(Some(_), None) => {
@@ -1041,20 +1049,23 @@ pub async fn project_edit_internal(
10411049
id,
10421050
new_project.minecraft_server,
10431051
&mut project_item.inner.components.minecraft_server,
1052+
perms,
10441053
)
10451054
.await?;
10461055
update(
10471056
&mut transaction,
10481057
id,
10491058
new_project.minecraft_java_server,
10501059
&mut project_item.inner.components.minecraft_java_server,
1060+
perms,
10511061
)
10521062
.await?;
10531063
update(
10541064
&mut transaction,
10551065
id,
10561066
new_project.minecraft_bedrock_server,
10571067
&mut project_item.inner.components.minecraft_bedrock_server,
1068+
perms,
10581069
)
10591070
.await?;
10601071

0 commit comments

Comments
 (0)