cirruslabs / orchard

Orchestrator for running Tart Virtual Machines on a cluster of Apple Silicon devices
Other
200 stars 17 forks source link

"PUT" requests to /service-account doesn't update roles #197

Closed mcmarkj closed 3 months ago

mcmarkj commented 3 months ago

Hi there. I'm trying to grant permissions to a role after the role has already been created by PUT'ing the changes to the endpoint. I believe in theory this should work but it doesn't actually update the role.

  1. Role before:
    {"token":"*redacted*","roles":["compute:read"],"name":"mark","createdAt":"2024-08-19T15:33:55.142170481Z"}
  2. I submit a PUT request to /v1/service-accounts/mark with the following body:
    {'name': 'mark', 'token': '*redacted*', 'roles': ['compute:read', 'admin:read']}
  3. I get a 200 back and the following is returned:
    {"token":"*redacted*","roles":["compute:read"],"name":"mark","createdAt":"2024-08-19T15:33:55.142170481Z"}

So the roles are not updated.

Am I misunderstanding what the PUT is for? Can it not update roles?

Thanks

mcmarkj commented 3 months ago

I've gotten around this for now by deleting and recreating the service account with the same token.

mcmarkj commented 3 months ago

Hey @edigaryev - thanks for the PR. I still can't seem to do a PUT to update roles however after updating to the latest version?

edigaryev commented 3 months ago

Hey @edigaryev - thanks for the PR. I still can't seem to do a PUT to update roles however after updating to the latest version?

Please make sure that you've updated your controller to 0.22.1.

The following cURL invocation seems to update the service account created with orchard create service-account test just fine on the latest Orchard release:

curl -u 'bootstrap-admin:<ORCHARD_BOOTSTRAP_ADMIN_TOKEN>' -k -X 'PUT' -d '{"name":"test","token":"not-so-secret","roles":["compute:write"]}' https://127.0.0.1:6120/v1/service-accounts/test
mcmarkj commented 3 months ago

Excellent, thank you @edigaryev - I wasn't sending through a list for the roles object, just a string. So changing that fixed it :)

Thanks again.