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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Coder plugin): Update integration with Backstage's identity API #118

Merged
merged 7 commits into from
Apr 19, 2024

Conversation

Parkreiner
Copy link
Collaborator

@Parkreiner Parkreiner commented Apr 18, 2024

Closes #116

Changes made

  • Updated all query logic to start using Backstage's Identity API properly
  • Added mock implementation of Identity API for tests
  • Added "pseudo-middleware" for MSW to ensure that our tests will fail if our main code fails to pass along the bearer token generated by the Identity API

Notes

  • The implementation in the main UI code is a little bit clunky. This is the sort of thing that the API refactor is meant to help clean up.
    • Once the refactor is done, bringing in and updating new Backstage APIs should be a lot more straightforward and plug-and-play
    • This PR is mainly meant to be a stopgap until the API refactor is fully completed. I'll make sure that the refactor includes equivalent identity logic

@Parkreiner Parkreiner self-assigned this Apr 18, 2024
mockCoderAuthToken,
mockBackstageProxyEndpoint as root,
} from './mockBackstageData';
import type { Workspace, WorkspacesResponse } from '../typesConstants';
import { CODER_AUTH_HEADER_KEY } from '../api';

type RestResolver<TBody extends DefaultBodyType = any> = ResponseResolver<
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of needing to bust out the any type for these MSW helper types, but it's what MSW itself is using, and trying to make things more specific got nasty

@Parkreiner
Copy link
Collaborator Author

@code-asher Would definitely appreciate your perspective on the token stuff. I was aware of bearer tokens, but for all the companies I've worked for so far, they were abstracted out enough on the frontend that I never needed to touch them

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@Parkreiner Parkreiner merged commit 04a1c15 into main Apr 19, 2024
2 checks passed
@Parkreiner Parkreiner deleted the mes/identity-api branch April 19, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coder plugin: Auth header bearer token isn't being forwarded to Backstage backend APIs
2 participants