Skip to content
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

Add Option for Delegation to Any User #134

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

APTy
Copy link
Contributor

@APTy APTy commented Apr 13, 2016

This change resolves #119 by adding an explicit option ("AnyUser") for a delegator to allow any user to decrypt requested data. This improves on the current design, where a delegator must specify an empty list of users for the same effect.

Adding the AnyUser Option

Commit 4093134 adds the initial enhancement by extending the API for Cache.AddKeyFromRecord(). At this point, the function signature for this function is getting pretty heavy, but as it's only used once in core/core.go, this is probably OK (The test dependencies may be another matter). We document that delegating to an empty list of users is deprecated functionality, but still support it. Also adds CLI support for the same flag.

Edit: The function signature for Cache.AddKeyFromRecord() now accepts a Usage object to simplify it's API.

Enforcing the AnyUser Option

Commit 5549d4c adds enforcement (thereby breaking backwards-compatibility) of the flag by returning an error in core/core.go if we don't receive a list of Users or if the AnyUser flag is not set. This break the old, undesired behavior, and have to update quite a few test vectors to reflect the new API.

Thoughts on rolling these changes out incrementally to allow applications time to upgrade to the modified /delegate API?

@@ -50,7 +50,7 @@ func TestCreate(t *testing.T) {

func TestSummary(t *testing.T) {
createJson := []byte("{\"Name\":\"Alice\",\"Password\":\"Hello\"}")
delegateJson := []byte("{\"Name\":\"Bob\",\"Password\":\"Rob\",\"Time\":\"2h\",\"Uses\":1}")
delegateJson := []byte("{\"Name\":\"Bob\",\"Password\":\"Rob\",\"Time\":\"2h\",\"Uses\":1,\"AnyUser\":true}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to test a lot of these with AnyUser: false to ensure that it fails in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I added AnyUser: true to preserve the original behavior of the tests, but I agree that we should test the alternate path as well.

@APTy
Copy link
Contributor Author

APTy commented Apr 21, 2016

@kisom please see my test update - I think this logic is best served in its own test, where it won't interfere with the intended behaviors of other tests.

@codecov-io
Copy link

codecov-io commented May 6, 2016

Current coverage is 55.03%

Merging #134 into master will increase coverage by +0.30%

@@             master       #134   diff @@
==========================================
  Files            12         12          
  Lines          1766       1779    +13   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            966        979    +13   
  Misses          615        615          
  Partials        185        185          

Powered by Codecov. Last updated by 9cf4858...263c73a

@kisom kisom self-assigned this May 6, 2016
@kisom
Copy link
Contributor

kisom commented May 6, 2016

@APTy I won't have time this week to review this, but I will be able to on Monday.

@jkroll-cf
Copy link
Contributor

I'm aware of one project abusing the current behavior (no users specified => all users have access). I'll update once they've fixed. Meanwhile, please don't merge this.

@kisom kisom added the blocked label May 9, 2016
Tyler J and others added 4 commits May 10, 2016 16:38
core: Add AnyUser field to DelegateRequest and pass to cache calls

keycache: Add AnyUser parameter to AddKeyFromRecord function signature

keycache_test: Add tests for AnyUser and update AddKeyFromRecord calls

cryptor: Update tests to AddKeyFromRecord to reflect API update

cmd/ro: Add bool flag for anyUser parameter

Note: This commit was further amended to change the AddKeyFromRecord
API to accept keycache.Usage as a parameter, which will make updating
usage simpler in the future.
keycache: Remove deprecated behavior in Usage.matches()

core: Add check during delegation for a User list or the AnyUser flag

tests: Add parameters to conform to new delegation requirements
core: Add unit tests scenarios

core: Check for a non-nil, but empty, Users list

keycache: Add unit tests
Output before change:
cryptor/cryptor_test.go:112:
github.com/cloudflare/redoctober/keycache.Usage composite literal uses
unkeyed fields
@kisom
Copy link
Contributor

kisom commented Oct 5, 2016

This has merge conflicts and needs to be rebased off master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Red October's basic access control mechanism should be monotone
4 participants