common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
956 stars 90 forks source link

Support customising user-facing error messages #603

Open chrnorm opened 5 months ago

chrnorm commented 5 months ago

From the Common Fate Community Slack:

I wonder if there is a way to customise the different messages of granted shows to the user. For instace, print a custom message when you need to run granted sso login again, like: Error when retrieving credentials from custom-process:

[✘] please re-login with 'devel-toolbox cloud-login', or directly using 'granted sso login --sso-start-url https://d-1234567.awsapps.com/start --sso-region us-west-2. See http://bit.ly/help-url for more info'

Or when there is an error:

[✘] operation error SSO: GetRoleCredentials, https response error StatusCode: 403, RequestID: 3dbf80a3-f4c3-4819-8e7e-91a9afdea5c7, api error ForbiddenException: No access
[i] It looks like you don't have the right permissions to access this role
[i] If you used JIT, remember to run 'reset-cloud-creds' and try again. Go to http://bit.ly/help-url troubleshooting

I’ve got a work-in-progress branch here where we return a NoAccessError if we get the ForbiddenException from AWS. We should be able to hook into this error and trigger a templated, configurable error message.

We can potentially use Go templates here too to allow you to include details on the particular profile which had the error too.