ss098 / certmagic-s3

Certmagic S3-compatible driver written in Go | Caddy 证书存储 Certmagic 接口分布式对象存储实现
49 stars 29 forks source link

join path properly #15

Closed midnight-wonderer closed 10 months ago

midnight-wonderer commented 11 months ago

This thing messed up my setup.
I believe this is the proper way to join paths.

Warning: untested code; I have no professional Golang experience.

ss098 commented 11 months ago

Hello,

Thanks for the PR.

Is it because the Prefix is not configured that the module cannot work?

midnight-wonderer commented 11 months ago

Hey, it kinda complicated

The S3-compatible storage I am using, allows setting key prefixes access control. For example, I can grant access to some/prefix/path to access key A; and some/other/path to access key B.

S3 is just a big KV store, it doesn't actually have a concept of directories.

That why:
To mimic the directory access grant, the only logical way to do it is to add a trailing / to the rule. Key A, which should be able to access some/prefix/path, should have the prefix rule of some/prefix/path/ (with trailing slash), because otherwise, it will be able to access some/prefix/path-and/some/other/adjacent/path too.

But once I add a trailing slash to the prefix rule:

Both have an issue:

There are two possible solutions on the top of my head, but this PR is the better one. Simply join paths like what average people expected. I want double slashes in the middle of file paths; said no one ever.