dub icon indicating copy to clipboard operation
dub copied to clipboard

add username and password to URL.toString()

Open Gagege opened this issue 3 years ago • 4 comments

I'm trying to set dubRegistry and use a Basic HTTP Auth (ie. https://username:[email protected]) URL. I ran into an issue because URL.toString doesn't output username@password. So here is my solution. Open to feedback, of course. Thanks!

Gagege avatar Jul 06 '21 14:07 Gagege

At least in dub registry the equivalent class had them omitted by design, where it rather added a constant ***@*** string if credentials are present, to not expose it in error messages.

However in dub (running on the users PC with the users settings) I think it's not harmful to include credentials in any case. I think from the start it would maybe have been better to have an explicit build method that includes all the data, but I think adding it now would be unnecessary.

It's worthy thinking of the security considerations of this in any case - if any malicious party for example can look over the output of the users run (log of a CI run with secret dub registry credentials) and the connection fails and causes the credentials to be printed - could this be considered a security risk?

You mixed tabs and spaces btw.

WebFreak001 avatar Jul 07 '21 09:07 WebFreak001

I see what you're saying @WebFreak001. What if I concatenated the username and password where it's needed in the download function instead? I'll update my PR anyway.

Gagege avatar Jul 07 '21 13:07 Gagege

Made an update. This should be safer, and backward compatible.

Gagege avatar Jul 07 '21 15:07 Gagege

@WebFreak001 @s-ludwig Do either of you know what happened with that failed build, DAutoTest? I can't find the actual error in it.

Gagege avatar Jul 08 '21 18:07 Gagege