posit-dev / publisher

MIT License
3 stars 0 forks source link

URL normalization in backend key storage #1740

Closed sagerb closed 2 months ago

sagerb commented 2 months ago

Intent

This code will normalize the URL that is stored with a credential. This URL is used as the basis of all server addresses, so this will provide consistency for our URL path building.

Fixes #1725

Note, this PR also takes the opportunity to remove the confusing "Example: " prefix within the placeholder for server URL within new credential flow.

Type of Change

Approach

Updated the central location (credentials.go where credentials are stored, to normalize the URL before inserting. To do this, I pulled out the normalization function that was being used by provider_env_var.go and relocated it into a utility function.

I decided that requiring internal dev users to remove their existing credentials was good enough, and that we didn't need to normalize the URLs everytime we pulled them out of storage. I had originally thought that I'd do this, as my existing credentials had a trailing /. However, because we are matching server URLs as to what has been written into the deployment file, having a different credential path coming out of credentials but not having the existing entries within deployment files updated, still caused mismatches.

Automated Tests

Directions for Reviewers

Remove your existing credentials and existing deployments. Then add a new credential, make sure you can deploy to it, and then follow the link to the content on the server. The original error occurred because the links within the deployment file contained multiple forward slashes in a row, which should not occur right now. When that was occurring, Safari would not follow the link correctly when the user was not logged into the server.

Checklist