-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
etcdctl/ctlv3: auth: how to create /home/ directory ? #6359
Comments
@soyking, does this capture your use case as well? |
yeah, I want this feature too:)
|
The permission supports range. You can do /home/xiang-> /home/xian+byte(g+1). We probably can make etcdctl better by adding a --prefix option to help users to do this calculation automatically. It would be great if you can contribute. The prefix generation code is here https://github.com/coreos/etcd/blob/master/clientv3/op.go#L214 |
Range is painful to use. For example, I don't know how to specify the I'd be happy to help if you're okay with implementing |
And, in my test, if you use the range such as |
@glycerine v3 API provides flat key space, it is essentially different from the Unix file system model. A key of etcd doesn't have a metadata like inode and there is no concept of directly. So we need to think with the range based permission. It is also required for effective range query. @soyking It is weird. I'll look at it and fix. |
Hi @mitake, the point was that the system should be able to model such common situations. At the risk of repeating an un-refuted observation, ranges are painful to use. To prove this, I issued a challenge, which has gone unmet. There's nothing in a flat keyspace that mandates the use of ranges. If it will be accepted when complete, I again offer to implement the much more usable wildcards. |
@glycerine Of course I don't disagree with the prefix based permission :) I wanted to say that etcd cannot have a thing like inode because it isn't a file system and we need to implement the prefix based checking on the range based checking like @xiang90 pointed. In addition, it allows a situation like this: some users can be granted to access to |
Hmm... indeed, How about, in addition to simple prefix + If a path ends in Thus the trailing
would be sufficient to set permissions for all keys that contained them as prefixes. Hence the common model of directories used in zookeeper and filesystems would be readily used. |
For example, #6371 would seem to accomplish this, would it not? |
I think I agree with your opinion that the prefix based permission is useful. However, mocking the entire semantics of the Unix file systems wouldn't be a good idea. The file system-like APIs would be comfortable because everyone knows it but it is not so strong (just directories + uninterpreted blob files). etcd v3 API is far convenient than the fs API: it already provides range query (AFAIK it is required by k8s for its scalability) and multiple key txn. In addition, secondary index seems to be supported in the future (https://speakerdeck.com/philips/etcd-next-steps-with-the-cornerstone-of-distributed-systems). These features are possible because etcd is essentially different from file systems. ZooKeeper and Chubby provides file system like APIs but they (especially Chubby) were designed years before. I'm not sure the design isn't a negative legacy in these days because if a storage system is not scale-out type, giving up rich data types and operations isn't necessary (e.g. Dynamo vs RDBMSes). |
Implement wildcards: when '*' or '/' are then last symbol in a key, they designate a prefix range implicitly. Also: many fencepost bugs fixed in the range merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcards for get, pul and del. When '*' or '/' is the last symbol in a key, the key is converted to a prefix range. Also: fix many fencepost bugs fixed in the range merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcards for get, pul and del. When '*' or '/' is the last symbol in a key, the key is converted to a prefix range. Also: fix many fencepost bugs fixed in the range merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
@mitake @glycerine etcd could cleanly support directory hierarchies and wildcards with a protocol extension proxy on the KV and Watch services with the regular etcd3 flat binary key-space underneath. That way the etcd core stays simple but server-imposed structure on the keyspace is still available for anyone that wants it. What do you think? |
@heyitsanthony yes supporting the file system like API as an extension seems to be a good idea. How will you implement it? Use some keys as inodes and others as blocks? |
@mitake -- It'll look like the v3 API except |
@heyitsanthony I see, thanks for the description. I agree with supporting the directory model in the proxy layer. |
I don't know how a protocol extension proxy works, but it sounds quite complex. |
@heyitsanthony hope to see that. Because now for the directory hierarchies, I have to get a key such as |
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
What I discovered in doing #6371 was that special handling for The implementation in #6371 is pretty complete now, modulo the unknown proxy ideas floating around. Give it a try and let me know if you find it usable from the shell; I find it pretty reasonable. The backslash escape ( |
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Implement wildcard '*' for get and del. When '*' is the last symbol in a key, the key is converted to a prefix range. The wildcard may only appear as the last symbol in a key. Also: fix several fencepost bugs fixed in the range sorting/merge code, including one incorrect test in auth/range_perm_cache_test.go Fixes etcd-io#6359
Hmm... I'm starting to understand the tradeoff here between usability from the command line, and usability from the API. The wildcard star However, as @heyitsanthony pointed out, that means that it is hard to write, from the command line, a key that ends with a star. One approach to this would be to move the transformation of terminating wildcard |
@glycerine Really, this should be done with a proxy; there's already some grpc proxy code in |
@glyercine do you only need to set roles for a prefix using |
@heyitsanthony, @mitake: etcdctl --prefix grant-permissions might do the job. If you're not going to merge it, you should at least cherry pick (manually) the range and range-merge logic fixes I did in #6371. There were a bunch of insidious and painful to track down logic bugs, as well as an incorrect test. Specifically: https://github.com/coreos/etcd/pull/6371/files#diff-e807c9d20ed5566b76a11ae69b345f44R40 https://github.com/coreos/etcd/pull/6371/files#diff-e807c9d20ed5566b76a11ae69b345f44R43 https://github.com/coreos/etcd/pull/6371/files#diff-e807c9d20ed5566b76a11ae69b345f44R100 (lines 100-108) https://github.com/coreos/etcd/pull/6371/files#diff-55d74d95bb1853641dbd100adbf43f80R109 |
@glycerine OK, the isSubset fix looks like the right thing to do. Not sure about the other ones (@mitake knows those paths better). We can do a bugfix PR if you want to be involved in that (if not, that's fine, I can pick it up for you). Thanks! |
We probably should still try to add --prefix option to auth permission as I mentioned in a previous reply. I agree with @glycerine that asking users to calculate what is the right range end for granting /xiang/* is not ideal. |
yes, please go ahead and run with an independent bugfix pr, I'm swamped. Questions though, let me know. The test (test 15, counting from zero, in TestGetMergedPerms in etcd/auth/range_perm_cache_test.go) was trying to say that [a, b) merged with [b, "") should be [a, b), which it is not; the two cannot be merged, because [a,b) is different from [a,b]; in the range convention used, [a,b] must be represented as two ranges. Second, the basic merge logic incorrectly handled the case of merging [a,b) with [b, ""), because it tried to (incorrectly) return [a, ""). Here "" means the empty string. |
@glycerine Thanks for your analysis and work so far. We will try to take it over, and fix the issues you reported soon. |
@glycerine Yes the existing range mechanism has some bugs. I'll cherry pick your commit and create a new PR. Thanks a lot for analysis and fix! |
Test 15, counting from zero, in TestGetMergedPerms in etcd/auth/range_perm_cache_test.go, was trying incorrectly assert that [a, b) merged with [b, "") should be [a, b). Added a test specifically for this. This patch fixes the incorrect larger test and the bugs in the code that it was hiding. Fixes etcd-io#6359
Test 15, counting from zero, in TestGetMergedPerms in etcd/auth/range_perm_cache_test.go, was trying incorrectly assert that [a, b) merged with [b, "") should be [a, b). Added a test specifically for this. This patch fixes the incorrect larger test and the bugs in the code that it was hiding. Fixes etcd-io#6359
Test 15, counting from zero, in TestGetMergedPerms in etcd/auth/range_perm_cache_test.go, was trying incorrectly assert that [a, b) merged with [b, "") should be [a, b). Added a test specifically for this. This patch fixes the incorrect larger test and the bugs in the code that it was hiding. Fixes etcd-io#6359
Test 15, counting from zero, in TestGetMergedPerms in etcd/auth/range_perm_cache_test.go, was trying incorrectly assert that [a, b) merged with [b, "") should be [a, b). Added a test specifically for this. This patch fixes the incorrect larger test and the bugs in the code that it was hiding. Fixes #6359
Related to the wilcard '*' discussion on #6355 #5896:
I have a set of clients. I would like to give each a /home/ sub-directory, so that they may write and read in their home directory. They should be able to read other people's home directories, but not write. For example:
So the permissions I would like to grant to each of my users would be:
role
user
can read on/home/*
while individual users can write on
/home/$USER/*
, where $USER is the current user.I would be fine, if really necessary, with creating a new role for each user,
in order to assign that role the write permission, for example: role jason would have write permission on
/home/jason/*
. This does seem a little tedious though.I am simply organizing my client-server communication using a model
that most users will be familiar with. Namely, the unix file system /home/
directory conventions.
Without
*
wildcard support, I don't see a way to do this. Could yousuggest a workaround, or consider implementing
*
wildcard support?The text was updated successfully, but these errors were encountered: