Rather than wait to make sure the user has the right permissions to use ncm-ci, wondering if we should perhaps check first. Then we could provide an error message indicating what permissions are required.
One reason to do this is that the error messages coming back from ncm2-api aren't really clear as to what the problem is, other than "auth errors". We could have ncm2-api actually return information regarding the permissions required, but ... that's slightly weird. I guess we would also have to return information regarding "roles" (if they passed a user token).
It's possible long-term we'll have a better story for customers here, but for now it seems like adding a token permission check in ncm-ci will be the simplest thing to do.
For reference, this is what accounts-api returns for GET /user/details when a service token is passed in the Auth header:
Somewhat related to: https://github.com/nodesource/accounts-ui/issues/500
Rather than wait to make sure the user has the right permissions to use
ncm-ci
, wondering if we should perhaps check first. Then we could provide an error message indicating what permissions are required.One reason to do this is that the error messages coming back from
ncm2-api
aren't really clear as to what the problem is, other than "auth errors". We could have ncm2-api actually return information regarding the permissions required, but ... that's slightly weird. I guess we would also have to return information regarding "roles" (if they passed a user token).It's possible long-term we'll have a better story for customers here, but for now it seems like adding a token permission check in
ncm-ci
will be the simplest thing to do.For reference, this is what accounts-api returns for
GET /user/details
when a service token is passed in the Auth header: