@backstage/plugin-search-backend 1.0.0 → 1.0.1-next.0
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/CHANGELOG.md +10 -0
- package/dist/index.cjs.js +120 -69
- package/dist/index.cjs.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @backstage/plugin-search-backend
|
|
2
2
|
|
|
3
|
+
## 1.0.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-common@0.15.0-next.0
|
|
9
|
+
- @backstage/plugin-auth-node@0.2.4-next.0
|
|
10
|
+
- @backstage/plugin-permission-node@0.6.4-next.0
|
|
11
|
+
- @backstage/plugin-search-backend-node@1.0.1-next.0
|
|
12
|
+
|
|
3
13
|
## 1.0.0
|
|
4
14
|
|
|
5
15
|
### Major Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -53,34 +53,52 @@ class AuthorizedSearchEngine {
|
|
|
53
53
|
}
|
|
54
54
|
async query(query, options) {
|
|
55
55
|
const queryStartTime = Date.now();
|
|
56
|
-
const conditionFetcher = new DataLoader__default["default"](
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const conditionFetcher = new DataLoader__default["default"](
|
|
57
|
+
(requests) => this.permissions.authorizeConditional(requests.slice(), options),
|
|
58
|
+
{
|
|
59
|
+
cacheKeyFn: ({ permission: { name } }) => name
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
const authorizer = new DataLoader__default["default"](
|
|
63
|
+
(requests) => this.permissions.authorize(requests.slice(), options),
|
|
64
|
+
{
|
|
65
|
+
cacheKeyFn: ({ permission: { name }, resourceRef }) => qs__default["default"].stringify({ name, resourceRef })
|
|
66
|
+
}
|
|
67
|
+
);
|
|
62
68
|
const requestedTypes = query.types || Object.keys(this.types);
|
|
63
|
-
const typeDecisions = lodash.zipObject(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
const typeDecisions = lodash.zipObject(
|
|
70
|
+
requestedTypes,
|
|
71
|
+
await Promise.all(
|
|
72
|
+
requestedTypes.map((type) => {
|
|
73
|
+
var _a;
|
|
74
|
+
const permission = (_a = this.types[type]) == null ? void 0 : _a.visibilityPermission;
|
|
75
|
+
if (!permission) {
|
|
76
|
+
return { result: pluginPermissionCommon.AuthorizeResult.ALLOW };
|
|
77
|
+
}
|
|
78
|
+
if (pluginPermissionCommon.isResourcePermission(permission)) {
|
|
79
|
+
return conditionFetcher.load({ permission });
|
|
80
|
+
}
|
|
81
|
+
return authorizer.load({ permission });
|
|
82
|
+
})
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
const authorizedTypes = requestedTypes.filter(
|
|
86
|
+
(type) => {
|
|
87
|
+
var _a;
|
|
88
|
+
return ((_a = typeDecisions[type]) == null ? void 0 : _a.result) !== pluginPermissionCommon.AuthorizeResult.DENY;
|
|
68
89
|
}
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
);
|
|
91
|
+
const resultByResultFilteringRequired = authorizedTypes.some(
|
|
92
|
+
(type) => {
|
|
93
|
+
var _a;
|
|
94
|
+
return ((_a = typeDecisions[type]) == null ? void 0 : _a.result) === pluginPermissionCommon.AuthorizeResult.CONDITIONAL;
|
|
71
95
|
}
|
|
72
|
-
|
|
73
|
-
})));
|
|
74
|
-
const authorizedTypes = requestedTypes.filter((type) => {
|
|
75
|
-
var _a;
|
|
76
|
-
return ((_a = typeDecisions[type]) == null ? void 0 : _a.result) !== pluginPermissionCommon.AuthorizeResult.DENY;
|
|
77
|
-
});
|
|
78
|
-
const resultByResultFilteringRequired = authorizedTypes.some((type) => {
|
|
79
|
-
var _a;
|
|
80
|
-
return ((_a = typeDecisions[type]) == null ? void 0 : _a.result) === pluginPermissionCommon.AuthorizeResult.CONDITIONAL;
|
|
81
|
-
});
|
|
96
|
+
);
|
|
82
97
|
if (!resultByResultFilteringRequired) {
|
|
83
|
-
return this.searchEngine.query(
|
|
98
|
+
return this.searchEngine.query(
|
|
99
|
+
{ ...query, types: authorizedTypes },
|
|
100
|
+
options
|
|
101
|
+
);
|
|
84
102
|
}
|
|
85
103
|
const { page } = decodePageCursor(query.pageCursor);
|
|
86
104
|
const targetResults = (page + 1) * this.pageSize;
|
|
@@ -88,8 +106,13 @@ class AuthorizedSearchEngine {
|
|
|
88
106
|
let nextPageCursor;
|
|
89
107
|
let latencyBudgetExhausted = false;
|
|
90
108
|
do {
|
|
91
|
-
const nextPage = await this.searchEngine.query(
|
|
92
|
-
|
|
109
|
+
const nextPage = await this.searchEngine.query(
|
|
110
|
+
{ ...query, types: authorizedTypes, pageCursor: nextPageCursor },
|
|
111
|
+
options
|
|
112
|
+
);
|
|
113
|
+
filteredResults = filteredResults.concat(
|
|
114
|
+
await this.filterResults(nextPage.results, typeDecisions, authorizer)
|
|
115
|
+
);
|
|
93
116
|
nextPageCursor = nextPage.nextPageCursor;
|
|
94
117
|
latencyBudgetExhausted = Date.now() - queryStartTime > this.queryLatencyBudgetMs;
|
|
95
118
|
} while (nextPageCursor && filteredResults.length < targetResults && !latencyBudgetExhausted);
|
|
@@ -105,33 +128,43 @@ class AuthorizedSearchEngine {
|
|
|
105
128
|
};
|
|
106
129
|
}
|
|
107
130
|
async filterResults(results, typeDecisions, authorizer) {
|
|
108
|
-
return lodash.compact(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
131
|
+
return lodash.compact(
|
|
132
|
+
await Promise.all(
|
|
133
|
+
results.map((result) => {
|
|
134
|
+
var _a, _b, _c;
|
|
135
|
+
if (((_a = typeDecisions[result.type]) == null ? void 0 : _a.result) === pluginPermissionCommon.AuthorizeResult.ALLOW) {
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
const permission = (_b = this.types[result.type]) == null ? void 0 : _b.visibilityPermission;
|
|
139
|
+
const resourceRef = (_c = result.document.authorization) == null ? void 0 : _c.resourceRef;
|
|
140
|
+
if (!permission || !resourceRef) {
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
if (!pluginPermissionCommon.isResourcePermission(permission)) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
`Unexpected conditional decision returned for non-resource permission "${permission.name}"`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return authorizer.load({ permission, resourceRef }).then(
|
|
149
|
+
(decision) => decision.result === pluginPermissionCommon.AuthorizeResult.ALLOW ? result : void 0
|
|
150
|
+
);
|
|
151
|
+
})
|
|
152
|
+
)
|
|
153
|
+
);
|
|
123
154
|
}
|
|
124
155
|
}
|
|
125
156
|
|
|
126
157
|
const jsonObjectSchema = zod.z.lazy(() => {
|
|
127
|
-
const jsonValueSchema = zod.z.lazy(
|
|
128
|
-
zod.z.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
158
|
+
const jsonValueSchema = zod.z.lazy(
|
|
159
|
+
() => zod.z.union([
|
|
160
|
+
zod.z.string(),
|
|
161
|
+
zod.z.number(),
|
|
162
|
+
zod.z.boolean(),
|
|
163
|
+
zod.z.null(),
|
|
164
|
+
zod.z.array(jsonValueSchema),
|
|
165
|
+
jsonObjectSchema
|
|
166
|
+
])
|
|
167
|
+
);
|
|
135
168
|
return zod.z.record(jsonValueSchema);
|
|
136
169
|
});
|
|
137
170
|
const allowedLocationProtocols = ["http:", "https:"];
|
|
@@ -147,17 +180,26 @@ async function createRouter(options) {
|
|
|
147
180
|
if ("authorizeConditional" in permissions) {
|
|
148
181
|
permissionEvaluator = permissions;
|
|
149
182
|
} else {
|
|
150
|
-
logger.warn(
|
|
183
|
+
logger.warn(
|
|
184
|
+
"PermissionAuthorizer is deprecated. Please use an instance of PermissionEvaluator instead of PermissionAuthorizer in PluginEnvironment#permissions"
|
|
185
|
+
);
|
|
151
186
|
permissionEvaluator = pluginPermissionCommon.toPermissionEvaluator(permissions);
|
|
152
187
|
}
|
|
153
|
-
const engine = config.getOptionalBoolean("permission.enabled") ? new AuthorizedSearchEngine(
|
|
188
|
+
const engine = config.getOptionalBoolean("permission.enabled") ? new AuthorizedSearchEngine(
|
|
189
|
+
inputEngine,
|
|
190
|
+
types,
|
|
191
|
+
permissionEvaluator,
|
|
192
|
+
config
|
|
193
|
+
) : inputEngine;
|
|
154
194
|
const filterResultSet = ({ results, ...resultSet }) => ({
|
|
155
195
|
...resultSet,
|
|
156
196
|
results: results.filter((result) => {
|
|
157
197
|
const protocol = new URL(result.document.location, "https://example.com").protocol;
|
|
158
198
|
const isAllowed = allowedLocationProtocols.includes(protocol);
|
|
159
199
|
if (!isAllowed) {
|
|
160
|
-
logger.info(
|
|
200
|
+
logger.info(
|
|
201
|
+
`Rejected search result for "${result.document.title}" as location protocol "${protocol}" is unsafe`
|
|
202
|
+
);
|
|
161
203
|
}
|
|
162
204
|
return isAllowed;
|
|
163
205
|
})
|
|
@@ -173,25 +215,34 @@ async function createRouter(options) {
|
|
|
173
215
|
}))
|
|
174
216
|
});
|
|
175
217
|
const router = Router__default["default"]();
|
|
176
|
-
router.get(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
218
|
+
router.get(
|
|
219
|
+
"/query",
|
|
220
|
+
async (req, res) => {
|
|
221
|
+
var _a;
|
|
222
|
+
const parseResult = requestSchema.safeParse(req.query);
|
|
223
|
+
if (!parseResult.success) {
|
|
224
|
+
throw new errors.InputError(`Invalid query string: ${parseResult.error}`);
|
|
225
|
+
}
|
|
226
|
+
const query = parseResult.data;
|
|
227
|
+
logger.info(
|
|
228
|
+
`Search request received: term="${query.term}", filters=${JSON.stringify(query.filters)}, types=${query.types ? query.types.join(",") : ""}, pageCursor=${(_a = query.pageCursor) != null ? _a : ""}`
|
|
229
|
+
);
|
|
230
|
+
const token = pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
231
|
+
req.header("authorization")
|
|
232
|
+
);
|
|
233
|
+
try {
|
|
234
|
+
const resultSet = await (engine == null ? void 0 : engine.query(query, { token }));
|
|
235
|
+
res.send(filterResultSet(toSearchResults(resultSet)));
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (error.name === "MissingIndexError") {
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
throw new Error(
|
|
241
|
+
`There was a problem performing the search query. ${error}`
|
|
242
|
+
);
|
|
191
243
|
}
|
|
192
|
-
throw new Error(`There was a problem performing the search query. ${error}`);
|
|
193
244
|
}
|
|
194
|
-
|
|
245
|
+
);
|
|
195
246
|
router.use(backendCommon.errorHandler());
|
|
196
247
|
return router;
|
|
197
248
|
}
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/service/AuthorizedSearchEngine.ts","../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { compact, zipObject } from 'lodash';\nimport qs from 'qs';\nimport DataLoader from 'dataloader';\nimport {\n EvaluatePermissionResponse,\n EvaluatePermissionRequest,\n AuthorizeResult,\n isResourcePermission,\n PermissionEvaluator,\n AuthorizePermissionRequest,\n QueryPermissionRequest,\n} from '@backstage/plugin-permission-common';\nimport {\n DocumentTypeInfo,\n IndexableResult,\n IndexableResultSet,\n QueryRequestOptions,\n QueryTranslator,\n SearchEngine,\n SearchQuery,\n} from '@backstage/plugin-search-common';\nimport { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport { Writable } from 'stream';\n\nexport function decodePageCursor(pageCursor?: string): { page: number } {\n if (!pageCursor) {\n return { page: 0 };\n }\n\n const page = Number(Buffer.from(pageCursor, 'base64').toString('utf-8'));\n if (isNaN(page)) {\n throw new InputError('Invalid page cursor');\n }\n\n if (page < 0) {\n throw new InputError('Invalid page cursor');\n }\n\n return {\n page,\n };\n}\n\nexport function encodePageCursor({ page }: { page: number }): string {\n return Buffer.from(`${page}`, 'utf-8').toString('base64');\n}\n\nexport class AuthorizedSearchEngine implements SearchEngine {\n private readonly pageSize = 25;\n private readonly queryLatencyBudgetMs: number;\n\n constructor(\n private readonly searchEngine: SearchEngine,\n private readonly types: Record<string, DocumentTypeInfo>,\n private readonly permissions: PermissionEvaluator,\n config: Config,\n ) {\n this.queryLatencyBudgetMs =\n config.getOptionalNumber('search.permissions.queryLatencyBudgetMs') ??\n 1000;\n }\n\n setTranslator(translator: QueryTranslator): void {\n this.searchEngine.setTranslator(translator);\n }\n\n async getIndexer(type: string): Promise<Writable> {\n return this.searchEngine.getIndexer(type);\n }\n\n async query(\n query: SearchQuery,\n options: QueryRequestOptions,\n ): Promise<IndexableResultSet> {\n const queryStartTime = Date.now();\n\n const conditionFetcher = new DataLoader(\n (requests: readonly QueryPermissionRequest[]) =>\n this.permissions.authorizeConditional(requests.slice(), options),\n {\n cacheKeyFn: ({ permission: { name } }) => name,\n },\n );\n\n const authorizer = new DataLoader(\n (requests: readonly AuthorizePermissionRequest[]) =>\n this.permissions.authorize(requests.slice(), options),\n {\n // Serialize the permission name and resourceRef as\n // a query string to avoid collisions from overlapping\n // permission names and resourceRefs.\n cacheKeyFn: ({ permission: { name }, resourceRef }) =>\n qs.stringify({ name, resourceRef }),\n },\n );\n\n const requestedTypes = query.types || Object.keys(this.types);\n\n const typeDecisions = zipObject(\n requestedTypes,\n await Promise.all(\n requestedTypes.map(type => {\n const permission = this.types[type]?.visibilityPermission;\n\n // No permission configured for this document type - always allow.\n if (!permission) {\n return { result: AuthorizeResult.ALLOW as const };\n }\n\n // Resource permission supplied, so we need to check for conditional decisions.\n if (isResourcePermission(permission)) {\n return conditionFetcher.load({ permission });\n }\n\n // Non-resource permission supplied - we can perform a standard authorization.\n return authorizer.load({ permission });\n }),\n ),\n );\n\n const authorizedTypes = requestedTypes.filter(\n type => typeDecisions[type]?.result !== AuthorizeResult.DENY,\n );\n\n const resultByResultFilteringRequired = authorizedTypes.some(\n type => typeDecisions[type]?.result === AuthorizeResult.CONDITIONAL,\n );\n\n // When there are no CONDITIONAL decisions for any of the requested\n // result types, we can skip filtering result by result by simply\n // skipping the types the user is not permitted to see, which will\n // be much more efficient.\n //\n // Since it's not currently possible to configure the page size used\n // by search engines, this detail means that a single user might see\n // a different page size depending on whether their search required\n // result-by-result filtering or not. We can fix this minor\n // inconsistency by introducing a configurable page size.\n //\n // cf. https://github.com/backstage/backstage/issues/9162\n if (!resultByResultFilteringRequired) {\n return this.searchEngine.query(\n { ...query, types: authorizedTypes },\n options,\n );\n }\n\n const { page } = decodePageCursor(query.pageCursor);\n const targetResults = (page + 1) * this.pageSize;\n\n let filteredResults: IndexableResult[] = [];\n let nextPageCursor: string | undefined;\n let latencyBudgetExhausted = false;\n\n do {\n const nextPage = await this.searchEngine.query(\n { ...query, types: authorizedTypes, pageCursor: nextPageCursor },\n options,\n );\n\n filteredResults = filteredResults.concat(\n await this.filterResults(nextPage.results, typeDecisions, authorizer),\n );\n\n nextPageCursor = nextPage.nextPageCursor;\n latencyBudgetExhausted =\n Date.now() - queryStartTime > this.queryLatencyBudgetMs;\n } while (\n nextPageCursor &&\n filteredResults.length < targetResults &&\n !latencyBudgetExhausted\n );\n\n return {\n results: filteredResults\n .slice(page * this.pageSize, (page + 1) * this.pageSize)\n .map((result, index) => {\n // Overwrite any/all rank entries to avoid leaking knowledge of filtered results.\n return {\n ...result,\n rank: page * this.pageSize + index + 1,\n };\n }),\n previousPageCursor:\n page === 0 ? undefined : encodePageCursor({ page: page - 1 }),\n nextPageCursor:\n !latencyBudgetExhausted &&\n (nextPageCursor || filteredResults.length > targetResults)\n ? encodePageCursor({ page: page + 1 })\n : undefined,\n };\n }\n\n private async filterResults(\n results: IndexableResult[],\n typeDecisions: Record<string, EvaluatePermissionResponse>,\n authorizer: DataLoader<\n EvaluatePermissionRequest,\n EvaluatePermissionResponse\n >,\n ) {\n return compact(\n await Promise.all(\n results.map(result => {\n if (typeDecisions[result.type]?.result === AuthorizeResult.ALLOW) {\n return result;\n }\n\n const permission = this.types[result.type]?.visibilityPermission;\n const resourceRef = result.document.authorization?.resourceRef;\n\n if (!permission || !resourceRef) {\n return result;\n }\n\n // We only reach this point in the code for types where the initial\n // authorization returned CONDITIONAL -- ALLOWs return early\n // immediately above, and types where the decision was DENY get\n // filtered out entirely when querying.\n //\n // This means the call to isResourcePermission here is mostly about\n // narrowing the type of permission - the only way to get here with a\n // non-resource permission is if the PermissionPolicy returns a\n // CONDITIONAL decision for a non-resource permission, which can't\n // happen - it would throw an error during validation in the\n // permission-backend.\n if (!isResourcePermission(permission)) {\n throw new Error(\n `Unexpected conditional decision returned for non-resource permission \"${permission.name}\"`,\n );\n }\n\n return authorizer\n .load({ permission, resourceRef })\n .then(decision =>\n decision.result === AuthorizeResult.ALLOW ? result : undefined,\n );\n }),\n ),\n );\n }\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { Logger } from 'winston';\nimport { z } from 'zod';\nimport { errorHandler } from '@backstage/backend-common';\nimport { ErrorResponseBody, InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport { getBearerTokenFromAuthorizationHeader } from '@backstage/plugin-auth-node';\nimport {\n PermissionAuthorizer,\n PermissionEvaluator,\n toPermissionEvaluator,\n} from '@backstage/plugin-permission-common';\nimport {\n DocumentTypeInfo,\n IndexableResultSet,\n SearchResultSet,\n} from '@backstage/plugin-search-common';\nimport { SearchEngine } from '@backstage/plugin-search-common';\nimport { AuthorizedSearchEngine } from './AuthorizedSearchEngine';\n\nconst jsonObjectSchema: z.ZodSchema<JsonObject> = z.lazy(() => {\n const jsonValueSchema: z.ZodSchema<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n jsonObjectSchema,\n ]),\n );\n\n return z.record(jsonValueSchema);\n});\n\n/**\n * @public\n */\nexport type RouterOptions = {\n engine: SearchEngine;\n types: Record<string, DocumentTypeInfo>;\n permissions: PermissionEvaluator | PermissionAuthorizer;\n config: Config;\n logger: Logger;\n};\n\nconst allowedLocationProtocols = ['http:', 'https:'];\n\n/**\n * @public\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { engine: inputEngine, types, permissions, config, logger } = options;\n\n const requestSchema = z.object({\n term: z.string().default(''),\n filters: jsonObjectSchema.optional(),\n types: z\n .array(z.string().refine(type => Object.keys(types).includes(type)))\n .optional(),\n pageCursor: z.string().optional(),\n });\n\n let permissionEvaluator: PermissionEvaluator;\n if ('authorizeConditional' in permissions) {\n permissionEvaluator = permissions as PermissionEvaluator;\n } else {\n logger.warn(\n 'PermissionAuthorizer is deprecated. Please use an instance of PermissionEvaluator instead of PermissionAuthorizer in PluginEnvironment#permissions',\n );\n permissionEvaluator = toPermissionEvaluator(permissions);\n }\n\n const engine = config.getOptionalBoolean('permission.enabled')\n ? new AuthorizedSearchEngine(\n inputEngine,\n types,\n permissionEvaluator,\n config,\n )\n : inputEngine;\n\n const filterResultSet = ({ results, ...resultSet }: SearchResultSet) => ({\n ...resultSet,\n results: results.filter(result => {\n const protocol = new URL(result.document.location, 'https://example.com')\n .protocol;\n const isAllowed = allowedLocationProtocols.includes(protocol);\n if (!isAllowed) {\n logger.info(\n `Rejected search result for \"${result.document.title}\" as location protocol \"${protocol}\" is unsafe`,\n );\n }\n return isAllowed;\n }),\n });\n\n const toSearchResults = (resultSet: IndexableResultSet): SearchResultSet => ({\n ...resultSet,\n results: resultSet.results.map(result => ({\n ...result,\n document: {\n ...result.document,\n authorization: undefined,\n },\n })),\n });\n\n const router = Router();\n router.get(\n '/query',\n async (\n req: express.Request,\n res: express.Response<SearchResultSet | ErrorResponseBody>,\n ) => {\n const parseResult = requestSchema.safeParse(req.query);\n\n if (!parseResult.success) {\n throw new InputError(`Invalid query string: ${parseResult.error}`);\n }\n\n const query = parseResult.data;\n\n logger.info(\n `Search request received: term=\"${\n query.term\n }\", filters=${JSON.stringify(query.filters)}, types=${\n query.types ? query.types.join(',') : ''\n }, pageCursor=${query.pageCursor ?? ''}`,\n );\n\n const token = getBearerTokenFromAuthorizationHeader(\n req.header('authorization'),\n );\n\n try {\n const resultSet = await engine?.query(query, { token });\n\n res.send(filterResultSet(toSearchResults(resultSet)));\n } catch (error) {\n if (error.name === 'MissingIndexError') {\n // re-throw and let the default error handler middleware captures it and serializes it with the right response code on the standard form\n throw error;\n }\n\n throw new Error(\n `There was a problem performing the search query. ${error}`,\n );\n }\n },\n );\n\n router.use(errorHandler());\n\n return router;\n}\n"],"names":["InputError","DataLoader","qs","zipObject","AuthorizeResult","isResourcePermission","compact","z","toPermission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CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,KAAK,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACvN,IAAI,MAAM,KAAK,GAAGU,oDAAqC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AACrF,IAAI,IAAI;AACR,MAAM,MAAM,SAAS,GAAG,OAAO,MAAM,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACzF,MAAM,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC5D,KAAK,CAAC,OAAO,KAAK,EAAE;AACpB,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE;AAC9C,QAAQ,MAAM,KAAK,CAAC;AACpB,OAAO;AACP,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACnF,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,CAAC,GAAG,CAACC,0BAAY,EAAE,CAAC,CAAC;AAC7B,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/service/AuthorizedSearchEngine.ts","../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { compact, zipObject } from 'lodash';\nimport qs from 'qs';\nimport DataLoader from 'dataloader';\nimport {\n EvaluatePermissionResponse,\n EvaluatePermissionRequest,\n AuthorizeResult,\n isResourcePermission,\n PermissionEvaluator,\n AuthorizePermissionRequest,\n QueryPermissionRequest,\n} from '@backstage/plugin-permission-common';\nimport {\n DocumentTypeInfo,\n IndexableResult,\n IndexableResultSet,\n QueryRequestOptions,\n QueryTranslator,\n SearchEngine,\n SearchQuery,\n} from '@backstage/plugin-search-common';\nimport { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport { Writable } from 'stream';\n\nexport function decodePageCursor(pageCursor?: string): { page: number } {\n if (!pageCursor) {\n return { page: 0 };\n }\n\n const page = Number(Buffer.from(pageCursor, 'base64').toString('utf-8'));\n if (isNaN(page)) {\n throw new InputError('Invalid page cursor');\n }\n\n if (page < 0) {\n throw new InputError('Invalid page cursor');\n }\n\n return {\n page,\n };\n}\n\nexport function encodePageCursor({ page }: { page: number }): string {\n return Buffer.from(`${page}`, 'utf-8').toString('base64');\n}\n\nexport class AuthorizedSearchEngine implements SearchEngine {\n private readonly pageSize = 25;\n private readonly queryLatencyBudgetMs: number;\n\n constructor(\n private readonly searchEngine: SearchEngine,\n private readonly types: Record<string, DocumentTypeInfo>,\n private readonly permissions: PermissionEvaluator,\n config: Config,\n ) {\n this.queryLatencyBudgetMs =\n config.getOptionalNumber('search.permissions.queryLatencyBudgetMs') ??\n 1000;\n }\n\n setTranslator(translator: QueryTranslator): void {\n this.searchEngine.setTranslator(translator);\n }\n\n async getIndexer(type: string): Promise<Writable> {\n return this.searchEngine.getIndexer(type);\n }\n\n async query(\n query: SearchQuery,\n options: QueryRequestOptions,\n ): Promise<IndexableResultSet> {\n const queryStartTime = Date.now();\n\n const conditionFetcher = new DataLoader(\n (requests: readonly QueryPermissionRequest[]) =>\n this.permissions.authorizeConditional(requests.slice(), options),\n {\n cacheKeyFn: ({ permission: { name } }) => name,\n },\n );\n\n const authorizer = new DataLoader(\n (requests: readonly AuthorizePermissionRequest[]) =>\n this.permissions.authorize(requests.slice(), options),\n {\n // Serialize the permission name and resourceRef as\n // a query string to avoid collisions from overlapping\n // permission names and resourceRefs.\n cacheKeyFn: ({ permission: { name }, resourceRef }) =>\n qs.stringify({ name, resourceRef }),\n },\n );\n\n const requestedTypes = query.types || Object.keys(this.types);\n\n const typeDecisions = zipObject(\n requestedTypes,\n await Promise.all(\n requestedTypes.map(type => {\n const permission = this.types[type]?.visibilityPermission;\n\n // No permission configured for this document type - always allow.\n if (!permission) {\n return { result: AuthorizeResult.ALLOW as const };\n }\n\n // Resource permission supplied, so we need to check for conditional decisions.\n if (isResourcePermission(permission)) {\n return conditionFetcher.load({ permission });\n }\n\n // Non-resource permission supplied - we can perform a standard authorization.\n return authorizer.load({ permission });\n }),\n ),\n );\n\n const authorizedTypes = requestedTypes.filter(\n type => typeDecisions[type]?.result !== AuthorizeResult.DENY,\n );\n\n const resultByResultFilteringRequired = authorizedTypes.some(\n type => typeDecisions[type]?.result === AuthorizeResult.CONDITIONAL,\n );\n\n // When there are no CONDITIONAL decisions for any of the requested\n // result types, we can skip filtering result by result by simply\n // skipping the types the user is not permitted to see, which will\n // be much more efficient.\n //\n // Since it's not currently possible to configure the page size used\n // by search engines, this detail means that a single user might see\n // a different page size depending on whether their search required\n // result-by-result filtering or not. We can fix this minor\n // inconsistency by introducing a configurable page size.\n //\n // cf. https://github.com/backstage/backstage/issues/9162\n if (!resultByResultFilteringRequired) {\n return this.searchEngine.query(\n { ...query, types: authorizedTypes },\n options,\n );\n }\n\n const { page } = decodePageCursor(query.pageCursor);\n const targetResults = (page + 1) * this.pageSize;\n\n let filteredResults: IndexableResult[] = [];\n let nextPageCursor: string | undefined;\n let latencyBudgetExhausted = false;\n\n do {\n const nextPage = await this.searchEngine.query(\n { ...query, types: authorizedTypes, pageCursor: nextPageCursor },\n options,\n );\n\n filteredResults = filteredResults.concat(\n await this.filterResults(nextPage.results, typeDecisions, authorizer),\n );\n\n nextPageCursor = nextPage.nextPageCursor;\n latencyBudgetExhausted =\n Date.now() - queryStartTime > this.queryLatencyBudgetMs;\n } while (\n nextPageCursor &&\n filteredResults.length < targetResults &&\n !latencyBudgetExhausted\n );\n\n return {\n results: filteredResults\n .slice(page * this.pageSize, (page + 1) * this.pageSize)\n .map((result, index) => {\n // Overwrite any/all rank entries to avoid leaking knowledge of filtered results.\n return {\n ...result,\n rank: page * this.pageSize + index + 1,\n };\n }),\n previousPageCursor:\n page === 0 ? undefined : encodePageCursor({ page: page - 1 }),\n nextPageCursor:\n !latencyBudgetExhausted &&\n (nextPageCursor || filteredResults.length > targetResults)\n ? encodePageCursor({ page: page + 1 })\n : undefined,\n };\n }\n\n private async filterResults(\n results: IndexableResult[],\n typeDecisions: Record<string, EvaluatePermissionResponse>,\n authorizer: DataLoader<\n EvaluatePermissionRequest,\n EvaluatePermissionResponse\n >,\n ) {\n return compact(\n await Promise.all(\n results.map(result => {\n if (typeDecisions[result.type]?.result === AuthorizeResult.ALLOW) {\n return result;\n }\n\n const permission = this.types[result.type]?.visibilityPermission;\n const resourceRef = result.document.authorization?.resourceRef;\n\n if (!permission || !resourceRef) {\n return result;\n }\n\n // We only reach this point in the code for types where the initial\n // authorization returned CONDITIONAL -- ALLOWs return early\n // immediately above, and types where the decision was DENY get\n // filtered out entirely when querying.\n //\n // This means the call to isResourcePermission here is mostly about\n // narrowing the type of permission - the only way to get here with a\n // non-resource permission is if the PermissionPolicy returns a\n // CONDITIONAL decision for a non-resource permission, which can't\n // happen - it would throw an error during validation in the\n // permission-backend.\n if (!isResourcePermission(permission)) {\n throw new Error(\n `Unexpected conditional decision returned for non-resource permission \"${permission.name}\"`,\n );\n }\n\n return authorizer\n .load({ permission, resourceRef })\n .then(decision =>\n decision.result === AuthorizeResult.ALLOW ? result : undefined,\n );\n }),\n ),\n );\n }\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { Logger } from 'winston';\nimport { z } from 'zod';\nimport { errorHandler } from '@backstage/backend-common';\nimport { ErrorResponseBody, InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport { getBearerTokenFromAuthorizationHeader } from '@backstage/plugin-auth-node';\nimport {\n PermissionAuthorizer,\n PermissionEvaluator,\n toPermissionEvaluator,\n} from '@backstage/plugin-permission-common';\nimport {\n DocumentTypeInfo,\n IndexableResultSet,\n SearchResultSet,\n} from '@backstage/plugin-search-common';\nimport { SearchEngine } from '@backstage/plugin-search-common';\nimport { AuthorizedSearchEngine } from './AuthorizedSearchEngine';\n\nconst jsonObjectSchema: z.ZodSchema<JsonObject> = z.lazy(() => {\n const jsonValueSchema: z.ZodSchema<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n jsonObjectSchema,\n ]),\n );\n\n return z.record(jsonValueSchema);\n});\n\n/**\n * @public\n */\nexport type RouterOptions = {\n engine: SearchEngine;\n types: Record<string, DocumentTypeInfo>;\n permissions: PermissionEvaluator | PermissionAuthorizer;\n config: Config;\n logger: Logger;\n};\n\nconst allowedLocationProtocols = ['http:', 'https:'];\n\n/**\n * @public\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { engine: inputEngine, types, permissions, config, logger } = options;\n\n const requestSchema = z.object({\n term: z.string().default(''),\n filters: jsonObjectSchema.optional(),\n types: z\n .array(z.string().refine(type => Object.keys(types).includes(type)))\n .optional(),\n pageCursor: z.string().optional(),\n });\n\n let permissionEvaluator: PermissionEvaluator;\n if ('authorizeConditional' in permissions) {\n permissionEvaluator = permissions as PermissionEvaluator;\n } else {\n logger.warn(\n 'PermissionAuthorizer is deprecated. Please use an instance of PermissionEvaluator instead of PermissionAuthorizer in PluginEnvironment#permissions',\n );\n permissionEvaluator = toPermissionEvaluator(permissions);\n }\n\n const engine = config.getOptionalBoolean('permission.enabled')\n ? new AuthorizedSearchEngine(\n inputEngine,\n types,\n permissionEvaluator,\n config,\n )\n : inputEngine;\n\n const filterResultSet = ({ results, ...resultSet }: SearchResultSet) => ({\n ...resultSet,\n results: results.filter(result => {\n const protocol = new URL(result.document.location, 'https://example.com')\n .protocol;\n const isAllowed = allowedLocationProtocols.includes(protocol);\n if (!isAllowed) {\n logger.info(\n `Rejected search result for \"${result.document.title}\" as location protocol \"${protocol}\" is unsafe`,\n );\n }\n return isAllowed;\n }),\n });\n\n const toSearchResults = (resultSet: IndexableResultSet): SearchResultSet => ({\n ...resultSet,\n results: resultSet.results.map(result => ({\n ...result,\n document: {\n ...result.document,\n authorization: undefined,\n },\n })),\n });\n\n const router = Router();\n router.get(\n '/query',\n async (\n req: express.Request,\n res: express.Response<SearchResultSet | ErrorResponseBody>,\n ) => {\n const parseResult = requestSchema.safeParse(req.query);\n\n if (!parseResult.success) {\n throw new InputError(`Invalid query string: ${parseResult.error}`);\n }\n\n const query = parseResult.data;\n\n logger.info(\n `Search request received: term=\"${\n query.term\n }\", filters=${JSON.stringify(query.filters)}, types=${\n query.types ? query.types.join(',') : ''\n }, pageCursor=${query.pageCursor ?? ''}`,\n );\n\n const token = getBearerTokenFromAuthorizationHeader(\n req.header('authorization'),\n );\n\n try {\n const resultSet = await engine?.query(query, { token });\n\n res.send(filterResultSet(toSearchResults(resultSet)));\n } catch (error) {\n if (error.name === 'MissingIndexError') {\n // re-throw and let the default error handler middleware captures it and serializes it with the right response code on the standard form\n throw error;\n }\n\n throw new Error(\n `There was a problem performing the search query. ${error}`,\n );\n }\n },\n );\n\n router.use(errorHandler());\n\n return router;\n}\n"],"names":["InputError","DataLoader","qs","zipObject","AuthorizeResult","isResourcePermission","compact","z","toPermissionEvaluator","Router","getBearerTokenFromAuthorizationHeader","errorHandler"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,SAAS,gBAAgB,CAAC,UAAU,EAAE;AAC7C,EAAE,IAAI,CAAC,UAAU,EAAE;AACnB,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACvB,GAAG;AACH,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3E,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE;AACnB,IAAI,MAAM,IAAIA,iBAAU,CAAC,qBAAqB,CAAC,CAAC;AAChD,GAAG;AACH,EAAE,IAAI,IAAI,GAAG,CAAC,EAAE;AAChB,IAAI,MAAM,IAAIA,iBAAU,CAAC,qBAAqB,CAAC,CAAC;AAChD,GAAG;AACH,EAAE,OAAO;AACT,IAAI,IAAI;AACR,GAAG,CAAC;AACJ,CAAC;AACM,SAAS,gBAAgB,CAAC,EAAE,IAAI,EAAE,EAAE;AAC3C,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC5D,CAAC;AACM,MAAM,sBAAsB,CAAC;AACpC,EAAE,WAAW,CAAC,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE;AACxD,IAAI,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACrC,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACvB,IAAI,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;AACnC,IAAI,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACvB,IAAI,IAAI,EAAE,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.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-search-backend",
|
|
3
3
|
"description": "The Backstage backend plugin that provides your backstage app with search",
|
|
4
|
-
"version": "1.0.0",
|
|
4
|
+
"version": "1.0.1-next.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"clean": "backstage-cli package clean"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@backstage/backend-common": "^0.
|
|
26
|
+
"@backstage/backend-common": "^0.15.0-next.0",
|
|
27
27
|
"@backstage/config": "^1.0.1",
|
|
28
28
|
"@backstage/errors": "^1.1.0",
|
|
29
|
-
"@backstage/plugin-auth-node": "^0.2.
|
|
29
|
+
"@backstage/plugin-auth-node": "^0.2.4-next.0",
|
|
30
30
|
"@backstage/plugin-permission-common": "^0.6.3",
|
|
31
|
-
"@backstage/plugin-permission-node": "^0.6.
|
|
32
|
-
"@backstage/plugin-search-backend-node": "^1.0.0",
|
|
31
|
+
"@backstage/plugin-permission-node": "^0.6.4-next.0",
|
|
32
|
+
"@backstage/plugin-search-backend-node": "^1.0.1-next.0",
|
|
33
33
|
"@backstage/plugin-search-common": "^1.0.0",
|
|
34
34
|
"@backstage/types": "^1.0.0",
|
|
35
35
|
"@types/express": "^4.17.6",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"zod": "^3.11.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@backstage/cli": "^0.18.0",
|
|
46
|
+
"@backstage/cli": "^0.18.1-next.0",
|
|
47
47
|
"@types/supertest": "^2.0.8",
|
|
48
48
|
"supertest": "^6.1.3"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"dist"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "fc3229c49caf6eced02ed9516199015bf4682664"
|
|
54
54
|
}
|