Search backend does not work when Backstage API requires auth
See original GitHub issueExpected Behavior
- Search backend worker process collates documents successfully
Current Behavior
- Search backend worker process fails with the error message below as no Authorization header is sent when fetching catalog entities.
2021-04-01T23:38:59.804Z search info Collating documents for software-catalog via DefaultCatalogCollator type=plugin
2021-04-01T23:38:59.810Z backstage info ::ffff:127.0.0.1 - - [01/Apr/2021:23:38:59 +0000] "GET /api/catalog/entities HTTP/1.1" 401 12 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" type=incomingRequest
(node:81127) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at http://localhost:7000/api/catalog/entities reason: Unexpected token U in JSON at position 0
at /adopter/backstage/node_modules/node-fetch/lib/index.js:272:32
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async DefaultCatalogCollator.execute (/adopter/backstage/node_modules/@backstage/plugin-catalog-backend/dist/index.cjs.js:3268:22)
at async /adopter/backstage/node_modules/@backstage/plugin-search-backend-node/dist/index.cjs.js:39:23
at async Promise.all (index 0)
(node:81127) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 16)
Possible Solution
- Have Search backend issue its own token to use when calling Backstage APIs (see https://github.com/backstage/backstage/blob/master/plugins/auth-backend/src/providers/google/provider.ts#L164 for a possible example). Add token as a parameter to IndexBuilder and DocumentCollator interface
Steps to Reproduce
- Follow instructions in https://github.com/backstage/backstage/blob/master/contrib/docs/tutorials/authenticate-api-requests.md on how to require authentication of the backstage api
- Start backstage
- Look at the logs to see the error message (search backend runs on a timer)
Context
Currently no impact as the search backend is not yet in use I think? When it is, I assume search will break for adopters using API auth.
Your Environment
- NodeJS Version (v12): v14
- Operating System and Version (e.g. Ubuntu 14.04): Mac OS X Catalina
- Browser Information:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Troubleshooting Auth
Auth is tricky and doesn't always work as expected. Below you'll find some of the common problems one might run into when setting...
Read more >backstage/plugin-auth-backend - npm package
Auth Backend. WORK IN PROGRESS. This is the backend part of the auth plugin. It responds to auth requests from the frontend, and...
Read more >backstage/plugin-auth-backend
A Backstage backend plugin that handles authentication. Latest version: 0.17.1, last published: a month ago.
Read more >Backstage by Example (Part 2) - John Tucker
If Backstage is configured to use GitHub Apps authentication you must grant ... (and thus be authorized) to use this Backstage App. To...
Read more >Penetration Test on Backstage
leading to potential authentication and authorization problems. ... No Authentication Required for sca older- backend. NONE. NOT.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The PR looks like just the thing. Have not tried it yet, but closing this issue with good faith in the implementors.
#7943 has been merged! the solution fixes the breaking collators. is this issue alright to close?