Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor scopes for media services #9153

Merged
merged 5 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Ethereal Engine. All Rights Reserved.
import { staticResourceFiltersQueryValidator } from '@etherealengine/engine/src/schemas/media/static-resource-filters.schema'
import { hooks as schemaHooks } from '@feathersjs/schema'

import { disallow, iff, isProvider } from 'feathers-hooks-common'
import verifyScope from '../../hooks/verify-scope'
import {
staticResourceFiltersExternalResolver,
Expand All @@ -38,16 +39,15 @@ export default {

before: {
all: [
verifyScope('admin', 'admin'),
() => schemaHooks.validateQuery(staticResourceFiltersQueryValidator),
schemaHooks.resolveQuery(staticResourceFiltersQueryResolver)
],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
find: [disallow()],
get: [iff(isProvider('external'), verifyScope('static_resource', 'read'))],
create: [disallow()],
update: [disallow()],
patch: [disallow()],
remove: [disallow()]
},
after: {
all: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ All portions of the code written by the Ethereal Engine team are Copyright 漏 20
Ethereal Engine. All Rights Reserved.
*/
import { hooks as schemaHooks } from '@feathersjs/schema'
import { disallow } from 'feathers-hooks-common'
import { disallow, iff, isProvider } from 'feathers-hooks-common'

import {
staticResourceDataValidator,
Expand Down Expand Up @@ -79,24 +79,21 @@ export default {
() => schemaHooks.validateQuery(staticResourceQueryValidator),
schemaHooks.resolveQuery(staticResourceQueryResolver)
],
find: [collectAnalytics()],
find: [iff(isProvider('external'), verifyScope('static_resource', 'read')), collectAnalytics()],
get: [disallow('external')],
create: [
iff(isProvider('external'), verifyScope('static_resource', 'write')),
setLoggedinUserInBody('userId'),
verifyScope('admin', 'admin'),
() => schemaHooks.validateData(staticResourceDataValidator),
schemaHooks.resolveData(staticResourceDataResolver)
],
update: [verifyScope('admin', 'admin')],
update: [disallow()],
patch: [
verifyScope('admin', 'admin'),
iff(isProvider('external'), verifyScope('static_resource', 'write')),
() => schemaHooks.validateData(staticResourcePatchValidator),
schemaHooks.resolveData(staticResourcePatchResolver)
],
remove: [
// iff(isProvider('external'), verifyScope('admin', 'admin') as any),
ensureResource
]
remove: [iff(isProvider('external'), verifyScope('static_resource', 'write')), ensureResource]
},

after: {
Expand Down