Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Parkreiner
Copy link
Member

@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
Member 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
Member 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
@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