Skip to content

Commit dae4f44

Browse files
committed
MBS-13108: Require relationship editor, not admin, privs for attributes
There's no real reason this should be locked behind account_admin. It has nothing to do with accounts nor private data, and a lot to do with schema / style, which is what we generally use relationship_editor for (not just relationships but also genres, instruments).
1 parent 9c2ff90 commit dae4f44

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

lib/MusicBrainz/Server/Controller/Attributes.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ sub attribute_index : Chained('attribute_base') PathPart('') {
9494
);
9595
}
9696

97-
sub create : Chained('attribute_base') RequireAuth(account_admin) SecureForm {
97+
sub create : Chained('attribute_base') RequireAuth(relationship_editor) SecureForm {
9898
my ($self, $c) = @_;
9999
my $model = $c->stash->{model};
100100

@@ -115,7 +115,7 @@ sub create : Chained('attribute_base') RequireAuth(account_admin) SecureForm {
115115
}
116116
}
117117

118-
sub edit : Chained('attribute_base') Args(1) RequireAuth(account_admin) SecureForm {
118+
sub edit : Chained('attribute_base') Args(1) RequireAuth(relationship_editor) SecureForm {
119119
my ($self, $c, $id) = @_;
120120
my $model = $c->stash->{model};
121121
my $attr = $c->model($model)->get_by_id($id);
@@ -137,7 +137,7 @@ sub edit : Chained('attribute_base') Args(1) RequireAuth(account_admin) SecureFo
137137
}
138138
}
139139

140-
sub delete : Chained('attribute_base') Args(1) RequireAuth(account_admin) SecureForm {
140+
sub delete : Chained('attribute_base') Args(1) RequireAuth(relationship_editor) SecureForm {
141141
my ($self, $c, $id) = @_;
142142
my $model = $c->stash->{model};
143143
my $attr = $c->model($model)->get_by_id($id)

t/lib/t/MusicBrainz/Server/Controller/Attributes/Delete.pm

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ test 'Delete standard attribute (series type)' => sub {
3131
$test->mech->get('/logout');
3232
$test->mech->get('/login');
3333
$test->mech->submit_form(
34-
with_fields => { username => 'admin', password => 'password' },
34+
with_fields => {
35+
username => 'relationship_editor',
36+
password => 'password',
37+
},
3538
);
3639

3740
$mech->get('/attributes/SeriesType/delete/1');
@@ -94,7 +97,10 @@ test 'Delete language' => sub {
9497
$test->mech->get('/logout');
9598
$test->mech->get('/login');
9699
$test->mech->submit_form(
97-
with_fields => { username => 'admin', password => 'password' },
100+
with_fields => {
101+
username => 'relationship_editor',
102+
password => 'password',
103+
},
98104
);
99105

100106
$mech->get_ok('/attributes/Language/delete/120');
@@ -157,7 +163,10 @@ test 'Delete script' => sub {
157163
$test->mech->get('/logout');
158164
$test->mech->get('/login');
159165
$test->mech->submit_form(
160-
with_fields => { username => 'admin', password => 'password' },
166+
with_fields => {
167+
username => 'relationship_editor',
168+
password => 'password',
169+
},
161170
);
162171

163172
$mech->get_ok('/attributes/Script/delete/28');

t/sql/attributes.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ INSERT INTO editor (
1111
id, name, password, ha1,
1212
email, email_confirm_date, privs)
1313
VALUES (
14-
2, 'admin', '{CLEARTEXT}password', '3a115bc4f05ea9856bd4611b75c80bca',
15-
'foo@example.com', now(), 128);
14+
2, 'relationship_editor', '{CLEARTEXT}password',
15+
'3a115bc4f05ea9856bd4611b75c80bca', 'foo@example.com', now(), 8);
1616

1717
-- Release for language and script usage
1818
INSERT INTO artist (

0 commit comments

Comments
 (0)