harness / backstage-plugins

Backstage Plugins for Harness Modules
Other
34 stars 26 forks source link

Harness CI plugin not working with new secured backend in Backstage 1.26+ #138

Closed stuartsaid closed 3 months ago

stuartsaid commented 4 months ago

In Backstage v1.26.0 the backend was made secure by default, this includes the backend proxy which is used with the harness CI plugin. https://backstage.io/docs/releases/v1.26.0#auth-improvements

However requests from the CI plugin frontend do not include an authorization token, and therefore are rejected by the backend. I believe this is because the standard JavaScript fetch is used in the line below (and potentially others). If this was changed to the one exported from Backstage, it should have the authorization token included and therefore work.

https://github.com/harness/backstage-plugins/blob/bf0dd73ed0926a936f92030cb17161d70ae9870b/plugins/harness-ci-cd/src/hooks/useGetExecutionsList.ts#L84-L91

Debanitrkl commented 4 months ago

Hi @stuartsaid thanks for pointing this out, we have already merged the fix https://github.com/harness/backstage-plugins/pull/136 for this, will release the newer version of the plugin soon, till then you can use the following in app-config.yaml to make the plugin work.

proxy:
    endpoints:
      '/harness/prod':
        target: https://app.harness.io/
+       credentials: dangerously-allow-unauthenticated
        headers:
          x-api-key: ${X-API-KEY}
Debanitrkl commented 4 months ago

@stuartsaid new version of the plugin is released please check now, it would be compatible with your version of backstage now.

stuartsaid commented 4 months ago

Thanks for the quick response @Debanitrkl. I have tested the plugin after the update, and unfortunately it still get's rejected by the proxy backend. I can see the Authorization token is now populated with the correct value, however it's missing the Bearer prefix. I've changed it in my node_modules to include Bearer xxx and it works, could you please amend?

Debanitrkl commented 4 months ago

I've changed it in my node_modules to include Bearer xxx and it works, could you please amend?

Thanks @stuartsaid yeah we take it on priority and get a new version released soon.

Debanitrkl commented 3 months ago

We have released a new plugin version this should solve your issue, please check