File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
packages/openneuro-server/src Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -138,13 +138,18 @@ export const checkDatasetWrite = async (
138138 // Quick path for anonymous writes
139139 throw new Error ( state . errorMessage )
140140 }
141- if ( userId && ! ( userInfo . email ) ) {
142- throw new Error ( "Connect an email to make contributions to OpenNeuro." )
143- }
144141 if ( userId && userInfo . admin ) {
145142 // Always allow site admins
146143 return true
147144 }
145+ // Allow worker scoped tokens to make admin actions on specific datasets
146+ if ( userId && userInfo ?. worker && datasetId === userInfo ?. dataset ) {
147+ return true
148+ }
149+ if ( userId && ! ( userInfo . email ) ) {
150+ throw new Error ( "Connect an email to make contributions to OpenNeuro." )
151+ }
152+ // Finally check the permissions model if other checks have not returned
148153 const permission = await Permission . findOne ( { datasetId, userId } ) . exec ( )
149154 if ( checkPermissionLevel ( permission , state ) ) {
150155 return true
Original file line number Diff line number Diff line change @@ -120,6 +120,14 @@ export const setupPassportAuth = () => {
120120 ( jwt , done ) => {
121121 if ( jwt . scopes ?. includes ( "dataset:indexing" ) ) {
122122 done ( null , { admin : false , blocked : false , indexer : true } )
123+ } else if ( jwt . scopes ?. includes ( "dataset:worker" ) ) {
124+ done ( null , {
125+ id : jwt . sub ,
126+ admin : false ,
127+ blocked : false ,
128+ worker : true ,
129+ dataset : jwt . dataset ,
130+ } )
123131 } else if ( jwt . scopes ?. includes ( "dataset:reviewer" ) ) {
124132 done ( null , {
125133 admin : false ,
You can’t perform that action at this time.
0 commit comments