json-rest-api 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -184,7 +184,8 @@ export async function compileSchemas (scope, deps) {
|
|
|
184
184
|
const schemaContext = {
|
|
185
185
|
fields: enrichedFields, // Mutable
|
|
186
186
|
originalFields: rawFields, // Read-only
|
|
187
|
-
scopeName
|
|
187
|
+
scopeName,
|
|
188
|
+
scopeOptions: scope.scopeOptions || {}
|
|
188
189
|
}
|
|
189
190
|
await runHooks('schema:enrich', schemaContext)
|
|
190
191
|
|
|
@@ -27,7 +27,6 @@ export const AccessPlugin = {
|
|
|
27
27
|
const evaluateOwnership = ({ record, field, schemaInfo, userId }) => {
|
|
28
28
|
if (!record) return 'unknown'
|
|
29
29
|
|
|
30
|
-
debugger
|
|
31
30
|
const idProperty = schemaInfo?.idProperty || 'id'
|
|
32
31
|
const schemaStructure = schemaInfo?.schemaStructure || {}
|
|
33
32
|
const schemaRelationships = schemaInfo?.schemaRelationships || {}
|
|
@@ -146,7 +145,6 @@ export const AccessPlugin = {
|
|
|
146
145
|
const auth = context.scopeOptions?.auth
|
|
147
146
|
if (!auth) return
|
|
148
147
|
|
|
149
|
-
debugger
|
|
150
148
|
scope.vars.authRules = auth
|
|
151
149
|
scope.vars.ownershipField = context.scopeOptions?.ownershipField
|
|
152
150
|
|
|
@@ -159,11 +157,11 @@ export const AccessPlugin = {
|
|
|
159
157
|
})
|
|
160
158
|
})
|
|
161
159
|
|
|
162
|
-
addHook('schema:enrich', 'rest-auth-auto-ownership-field', {}, ({ context
|
|
160
|
+
addHook('schema:enrich', 'rest-auth-auto-ownership-field', {}, ({ context }) => {
|
|
163
161
|
if (!config.ownership.enabled) return
|
|
164
|
-
const { fields, scopeName } = context
|
|
162
|
+
const { fields, scopeName, scopeOptions = {} } = context
|
|
165
163
|
if (config.ownership.excludeResources.includes(scopeName)) return
|
|
166
|
-
if (scopeOptions
|
|
164
|
+
if (scopeOptions.ownership === false) return
|
|
167
165
|
|
|
168
166
|
const field = ownershipField()
|
|
169
167
|
const relationshipName = fields[field]?.as || fields[field]?.belongsTo || field
|
|
@@ -285,7 +283,6 @@ export const AccessPlugin = {
|
|
|
285
283
|
|
|
286
284
|
addHook('checkPermissions', 'rest-auth-enforce', { sequence: -100 }, async ({ context, scope, scopeName }) => {
|
|
287
285
|
const operation = context.method
|
|
288
|
-
debugger
|
|
289
286
|
const scopeVars = scope?.vars
|
|
290
287
|
const authRules = scopeVars?.authRules
|
|
291
288
|
const minimalRecord = context.originalContext?.minimalRecord
|
|
@@ -300,7 +297,6 @@ export const AccessPlugin = {
|
|
|
300
297
|
const failures = []
|
|
301
298
|
|
|
302
299
|
for (const rule of rules) {
|
|
303
|
-
// if (rule === 'owns') debugger
|
|
304
300
|
try {
|
|
305
301
|
const [checkerName, ...paramParts] = rule.split(':')
|
|
306
302
|
const checker = state.authCheckers.get(checkerName)
|