Skip to content

[RSDK-8045] [RSDK-8366] Simultaneous Auth for App and Machine #326

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

Merged
merged 6 commits into from
Jul 29, 2024

Conversation

njooma
Copy link
Member

@njooma njooma commented Jul 23, 2024

This PR enables getting a machine client from an already-authenticated Viam client.

It also introduces a few breaking changes, all of the same type: in the AppClient, there were many instances of methods returning pb.Response.AsObject rather than the actual type underneath the response, e.g. pb.Robot.AsObject:

// We were returning
return response.toObject()

// when we should've been returning
return response.toObject().robot

This PR also goes through and explicitly adds return types for app client so that we get compile-time errors in future.

Once this is approved, I will make an announcement regarding this breaking change. Specifically the functions that are affected are:

  • getOrganization
  • createOrganizationInvite
  • updateOrganizationInviteAuthorizations
  • resendOrganizationInvite
  • createLocation
  • getLocation
  • updateLocation
  • locationAuth
  • createLocationSecret
  • getRobot
  • updateRobotPart
  • createRobotPartSecret
  • updateRobot
  • getFragment
  • createFragment
  • updateFragment
  • getRegistryItem
  • getModule

@njooma njooma requested a review from a team as a code owner July 23, 2024 20:58
Copy link
Member

@purplenicole730 purplenicole730 left a comment

Choose a reason for hiding this comment

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

It took me a while to look through, but the changes look really good to me! I enjoyed seeing the improved tests.

@@ -571,7 +592,7 @@ export class AppClient {
pb.LocationAuthRequest,
pb.LocationAuthResponse
>(service.locationAuth.bind(service), req);
return response.toObject();
return response.toObject().auth;
Copy link
Member

Choose a reason for hiding this comment

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

Following the previous functions, this return should be return response.getAuth()?.toObject(). The following functions after this one, however, follow this pattern of response.toObject()._. Wanted to point it out in case we had a preference.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had changed some of them to be response.getFoo().toObject() and kept some as response.toObject().foo because I had a slight inkling that converting the entire message to a JS object would be slower than getting only the attribute we want and then calling toObject() on that. However, so many of these responses only had a single attribute that I figured it probably didn't actually make much of a difference.

I perhaps should've done some benchmarking instead of making assumptions...

Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@purplenicole730 purplenicole730 left a comment

Choose a reason for hiding this comment

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

Oh whoops, meant to approve with my comment.

@njooma njooma merged commit bcbd6cd into viamrobotics:main Jul 29, 2024
3 checks passed
@njooma njooma deleted the RSDK-8045/simul-auth branch July 29, 2024 16:07
@10zingpd 10zingpd changed the title [RSDK-8045] Simultaneous Auth for App and Machine [RSDK-8045] [RSDK-8366] Simultaneous Auth for App and Machine Jul 30, 2024
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.

3 participants