You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Alexey Serbin (Code Review)" <ge...@cloudera.org> on 2017/02/07 20:12:58 UTC

[kudu-CR] WIP [security] tailored TokenSigner for system catalog

Alexey Serbin has uploaded a new change for review.

  http://gerrit.cloudera.org:8080/5930

Change subject: WIP [security] tailored TokenSigner for system catalog
......................................................................

WIP [security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation to loading
public part of token signing keys from the system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of Init().
That's the sequence to be exercised by a master server upon becoming
a leader.  It's possible to run this sequence multiple times
on the same instance of TokenSigner, generating new signing keys
only when already existing signing keys are about to expire.

Also, the TokenSigner class now embeds the logic to rotate its
signing key on Init(), if necessary.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/security/token-test.cc
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
5 files changed, 293 insertions(+), 48 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/1
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 13:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/5930/13/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS13, Line 100:     // If it's past the key's activity period, it's too late to use it
              :     // for signing: do not consider it as an active key candidate.
              :  
no need to change this, but I wonder whether we should still consider it, even if it's past this period. Isn't it better to have _some_ key to use for signing (even if it's past-due for rotation) rather than have to generate a new one which hasn't propagated yet?

It's likely a moot point because it only matters if your cluster goes down for a day, but maybe we could just remove these lines.


PS13, Line 107:     // The criterion is:
              :     //   (expire_time - validity_interval) + 2 * rotation_interval <= now
              :     //
              :  
nit: no need to duplicate the contents of the below statement


PS13, Line 191:   // The criterion is:
              :   //   (expire_time - validity_interval) + rotation_interval <= now
              :  
nit: this is just repeating what's in the code just below


Line 252:   //   (expire_time - validity_interval) + 2 * rotation_interval <= now
same


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 13
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 14:

(18 comments)

http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/master/master.cc
File src/kudu/master/master.cc:

PS14, Line 59: n
> capitalize here and below
I thought we have switched to the style with lower-case letters for description of the flags.  All right, I'll will return that back.


http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS14, Line 71:  &
> ampersand with type
woops, I thought it has been fixed already.


Line 97:       RETURN_NOT_OK(verifier_->ImportKeys({ public_key_pb }));
> Is this the only place this is called?  Could consider either batch importi
I don't think it's worth adding a method just for this case.  Batching keys import would make the code more complex: it would be necessary to partially duplicate the logic and make a second pass over the input keys.


Line 107:   tsk_deque_.clear();
> Does this need to check that the imported keys are more recent than the cur
Good catch. Yes, I think it's worth to be a little bit more defensive here.


Line 168:   const auto* key = tsk_deque_.front().get();
> I'm confused by this algorithm.  I would have expected the criteria about w
Try to think of that the following way:

* It's not worth creating a new key before reaching 'computed' active phase of the current key (that's about the second step of the algorithm you describe).  This also addresses cases when previously stored key generated with shorter rotation interval is loaded into a master instance running with longer  rotation interval. 
* a new key is not created if there are 2 keys in the queue already.
* once there are 2 keys in the queue and CheckNeedKey() returns false, a call to TryRotate() will eventually pop the inactive key out of the queue, setting the next key as the active one.
* the CheckNeedKey()/AddKey() + TryRotate() sequence is being called periodically, much often than the rotation interval.

To me, this simplifies this algorithm so it's not necessary to look into any other key besides the very first in the keys queue.  BTW, if looking at the expiration time of not the very first key in the queue, but the last one, it's also necessary to set the expiration time of the next key based not on WallTime_Now(), but on the expire time of the last key as well.  Also, I don't think the 'active phase start' criterion is applicable to any other key except for the current one.

I don't think current algorithm rotates more aggressively than it's necessary.  It _would_ if it were allowing to create a new key when there are 2 keys in the queue.

However, if you feel strong about this, we can try to converge on something which seems acceptable to you.


Line 176:   if (key->expire_time() - key_validity_seconds_ + key_rotation_seconds_ <=
> For clarity, consider changing this to
Interesting.  To me it's much easier to look at that in the absolute time scale, not intervals.  The diagram above is for illustration of that relation.  The code you propose is much harder to me to comprehend and ensure it's correct. :)

Would it help if I add the parenthesis to separate key's creation time:

if ((key->expire_time() - key_validity_seconds_) + key_rotation_seconds_ <= now) {
  ...
}

Or:

const auto key_creation_time = key->expire_time() - key_validity_seconds_;

if (key_creation_time + key_rotation_seconds_ <= now) {
  ...
}

?


PS14, Line 177:  now)
> this wrap is hurting legibility.
Done


PS14, Line 209:   tsk_deque_.emplace_back();
              :   tsk.swap(tsk_deque_.back());
> shouldn't this just be
yep, that would be easier to read.


Line 225:   bool rotated = false;
> I think this would be simpler if you initially set has_rotated to false, th
Done


Line 234:   if (key->expire_time() - key_validity_seconds_ + 2 * key_rotation_seconds_ <=
> Same as above, consider
The same -- to me it's much easier to compare points in the absolute time scale.


PS14, Line 235: WallTime_Now()
> Was the WallTime_Now() done outside the lock for perf reasons above?  If so
That time WallTime_Now() was called outside the lock for consistency -- it was necessary to supply that value in more than one place.  Why is that perfomance-wise beneficial to call WallTime_Now() outside of the lock?


Line 235:       WallTime_Now()) {
> Same, confusing wrap.
Done


PS14, Line 253: unique_ptr<TokenSigningPrivateKey> new_tsk(
              :       new TokenSigningPrivateKey(key_seq_num, key_expiration, std::move(key)));
              :   tsk->swap(new_tsk);
> *tsk = new TokenSigningPrivateKey(...)
replaced with tsk.reset(new ...)


http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS14, Line 44: aggregated
> 'included' may be clearer than 'aggregated' here and below
Done


PS14, Line 92: TSK considered
> TSK is considered
Done


PS14, Line 183: possible to
              :   // examine the key process the key as needed
> nit
Done


Line 198:   Status CheckNeedKey(std::unique_ptr<TokenSigningPrivateKey>* tsk) const;
> WARN_UNUSED_RESULT here and below.
Done


Line 222:   const TokenVerifier& verifier() { return *verifier_; }
> I think this should be a const method.
sure


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 14
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#14).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading/storing TSKs
(Token Signing Keys) in system catalog.

The expected use-case for the TokenSigner is calling ImportKey() on
elected-as-leader callback with entries loaded from the system catalog
table, and then calling CheckNeedKey()/AddKey(), TryRotateKey() sequence.
Further down the road, it's necessary to call the CheckNeedKey()/AddKey(),
TryRotateKey() sequence periodically to generate and activate new TSKs.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master-test.cc
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/rpc/negotiation-test.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
M src/kudu/tserver/heartbeater.cc
17 files changed, 785 insertions(+), 334 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/14
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 14
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 11:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/5930/11/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS11, Line 103: //   propagation interval: 1 day
> it's a bit odd that propagation = rotation interval in this diagram. Althou
That's the timings of the original diagram.  I thought it's worth introducing parameters which explicitly map into the essence of the TSK lifecycle, so it's easier to understand the constraints behind, etc.

OK, if the consensus is that we are better off with having less parameters and we it's unlikely to need customization here,  I'll drop that configurable propagation interval and assume it always equals to the rotation interval.


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 11
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 17:

I put up a separate patch here: http://gerrit.cloudera.org:8080/6075 (on top of this one) which does the above shared_ptr thing. It's not the prettiest but it works! able to connect via token to the cluster in Java now.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 17
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] WIP [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#3).

Change subject: WIP [security] tailored TokenSigner for system catalog
......................................................................

WIP [security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation to loading
public part of token signing keys from the system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of Init().
That's the sequence to be exercised by a master server upon becoming
a leader.  It's possible to run this sequence multiple times
on the same instance of TokenSigner, generating new signing keys
only when already existing signing keys are about to expire.

Also, the TokenSigner class now embeds the logic to rotate its
signing key on Init(), if necessary.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/authn_token_manager.cc
M src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
8 files changed, 307 insertions(+), 54 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/3
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 3
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 14:

(18 comments)

http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/master/master.cc
File src/kudu/master/master.cc:

PS14, Line 59: n
capitalize here and below


http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS14, Line 71:  &
ampersand with type


Line 97:       RETURN_NOT_OK(verifier_->ImportKeys({ public_key_pb }));
Is this the only place this is called?  Could consider either batch importing the keys, or just changing it to take a single key.


Line 107:   tsk_deque_.clear();
Does this need to check that the imported keys are more recent than the current keys in the deque?


Line 168:   const auto* key = tsk_deque_.front().get();
I'm confused by this algorithm.  I would have expected the criteria about whether a new key is needed to only depend on the last key in the queue.

  - If there is no second key in the queue, then always get a new key
  - then, I would check the condition you have below, but based on the last key's expire_time.

This would have the effect of double rotating the initial key, but I think the header comment is saying we should probably do that anyway.  I *think* the current algorithm would rotate much more aggressively than necessary, but I haven't tested that hypothesis.


Line 176:   if (key->expire_time() - key_validity_seconds_ + key_rotation_seconds_ <=
For clarity, consider changing this to

    auto remaining_period = key->expire_time() - now;
    if (remaining_period <= key_validity_seconds_ - key_rotation_seconds_) {
        ....
    }

I found that a little easier to reason through.


PS14, Line 177:  now)
this wrap is hurting legibility.


PS14, Line 209:   tsk_deque_.emplace_back();
              :   tsk.swap(tsk_deque_.back());
shouldn't this just be

    tsk_deque_.emplace_back(std::move(tsk))


Line 225:   bool rotated = false;
I think this would be simpler if you initially set has_rotated to false, then only change it in the 1 success path.


Line 234:   if (key->expire_time() - key_validity_seconds_ + 2 * key_rotation_seconds_ <=
Same as above, consider

    auto remaining_period = key->expire_time() - now;
    if (remaining_period <= key_validity_seconds_ - 2 * key_rotation_seconds_) {
        ....
    }


PS14, Line 235: WallTime_Now()
Was the WallTime_Now() done outside the lock for perf reasons above?  If so consider doing that here as well.


Line 235:       WallTime_Now()) {
Same, confusing wrap.


PS14, Line 253: unique_ptr<TokenSigningPrivateKey> new_tsk(
              :       new TokenSigningPrivateKey(key_seq_num, key_expiration, std::move(key)));
              :   tsk->swap(new_tsk);
*tsk = new TokenSigningPrivateKey(...)


http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS14, Line 44: aggregated
'included' may be clearer than 'aggregated' here and below


PS14, Line 92: TSK considered
TSK is considered


PS14, Line 183: possible to
              :   // examine the key process the key as needed
nit


Line 198:   Status CheckNeedKey(std::unique_ptr<TokenSigningPrivateKey>* tsk) const;
WARN_UNUSED_RESULT here and below.


Line 222:   const TokenVerifier& verifier() { return *verifier_; }
I think this should be a const method.


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 14
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 15:

> Checkout server_base.h, it's grown a TokenVerifier field.  In the master, we'll want to use the TokenVerifier internal to this TokenSigner, while on the tablet server, we'll want to use a standalone one.  Not sure the best way to do that, but it needs to be solved, otherwise the RPC system on the master won't be able to verify tokens.

Todd and I just discussed this offline.  Looks like the best route is to make a virtual method getters for the TokenVerifier on ServerBase, and then master can implement those through the TokenSigner, and tserver can implement them through a new TokenVerifier field.  The existing TokenVerifier field on ServerBase can be removed.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 15
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has submitted this change and it was merged.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading/storing TSKs
(Token Signing Keys) in system catalog.

The expected use-case for the TokenSigner is calling ImportKey() on
elected-as-leader callback with entries loaded from the system catalog
table, and then calling CheckNeedKey()/AddKey(), TryRotateKey() sequence.
Further down the road, it's necessary to call the CheckNeedKey()/AddKey(),
TryRotateKey() sequence periodically to generate and activate new TSKs.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Reviewed-on: http://gerrit.cloudera.org:8080/5930
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>
Reviewed-by: Dan Burkert <da...@apache.org>
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master-test.cc
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/rpc/negotiation-test.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
M src/kudu/tserver/heartbeater.cc
17 files changed, 801 insertions(+), 334 deletions(-)

Approvals:
  Dan Burkert: Looks good to me, approved
  Todd Lipcon: Looks good to me, approved
  Kudu Jenkins: Verified



-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 20
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#8).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey().  Then, the public part of the newly generated
TSK is stored into the system table.  If the data successfully stored,
call SetSigningKey() to set the newly generated TSK as TokenSigner's
signing key.  That's also the sequence to be exercised by a master
server upon becoming a leader.  It's possible to run this sequence
multiple times on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
14 files changed, 751 insertions(+), 304 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/8
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 8
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 19: Code-Review+2

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 19
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 10:

(23 comments)

http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/master/master.cc
File src/kudu/master/master.cc:

PS10, Line 116:                         FLAGS_token_signing_key_validity_seconds,
              :                                       FLAGS_token_signing_key_rotation_seconds,
              :                                       FLAGS_token_signing_key_propagation_seconds));
              :  
> nit: weird indentation
Done


PS10, Line 124:     RETURN_NOT_OK(token_signer_->TryAddKey(&key));
              :     if (key) {
              :       RETURN_NOT_OK(token_signer_->AddKey(std::move(key)));
> this looks kind of strange to me. If "TryAddKey" succeeds, then why are we 
Agree, let me rename TryAddKey ---> CheckNeedKey


http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS10, Line 56: DEFINE_int64(token_signing_key_rotation_seconds, 60 * 60 * 24 * 6,
             :              "number of seconds prior of the expiration time of current "
             :              "signing key when next key should be activated");
             : T
> this config seems a bit "backwards" to me. I would expect if I set this to 
Since we don't track the creation time of a key, but the expiration time, this seemed to me as more reliable way to describe and track the rotation schedule.  Otherwise, in case of multi-master setup there might be extra keys generated when leadership switches from one master to another.  I.e., for key rotation I think it's better to rely less on the ephemeral run-time state of master processes.


Line 62: DEFINE_int64(token_signing_key_propagation_seconds, 60,
> I'm a little confused by this flag.  Shouldn't we just check that tsk_valid
In essence we need to make sure that the public part of the new key appears in the master-->tserver HB response before we make the key active.  I.e., there should be some time delta after a new was generated prior to making it active.

As for the relation to the diagram, that diagram assumes rotation interval is equal to the propagation interval.

The translation map between the terms of the diagram in the block comment of the header file and these parameters:

'validity period'   <==> 'FLAGS_token_signing_key_validity_seconds'

'rotation interval' <==> 'FLAGS_token_signing_key_validity_seconds - FLAGS_token_signing_key_rotaion_seconds'

N/A                 <==> 'FLAGS_token_signing_key_propagation_seconds'


Also, varying token_signing_key_propagation_seconds parameter helps in testing scenarios.


PS10, Line 51: DEFINE_int64(token_signing_key_validity_seconds, 60 * 60 * 24 * 7,
             :              "number of seconds that a token signing key is valid for");
             : TAG_FLAG(token_signing_key_validity_seconds, advanced);
             : TAG_FLAG(token_signing_key_validity_seconds, experimental);
             : 
             : DEFINE_int64(token_signing_key_rotation_seconds, 60 * 60 * 24 * 6,
             :              "number of seconds prior of the expiration time of current "
             :              "signing key when next key should be activated");
             : TAG_FLAG(token_signing_key_rotation_seconds, advanced);
             : TAG_FLAG(token_signing_key_rotation_seconds, experimental);
             : 
             : DEFINE_int64(token_signing_key_propagation_seconds, 60,
             :              "time necessary to propagate public part of TSK "
             :              "via tserver-to-master heartbeats with some margin");
             : TAG_FLAG(token_signing_key_propagation_seconds, advanced);
             : TAG_FLAG(token_signing_key_propagation_seconds, experimental);
> I think these should be defined in master.cc where they're used - was surpr
It seems I ended up putting it into wrong place -- I started with having them in master.cc.

I'll move these, thank you for the clarification.


PS10, Line 89: // Reload the TSKs (presumably originated from the system catalog table).
             : // This method can be called multiple times.
> this doc should probably be in the header, not on the impl.
Done


PS10, Line 91:  &k
> nit: & goes with type
Done


PS10, Line 111:     if (next_key_seq_num_ <= seq_num) {
              :       // Advance the key sequence number, if needed.
              :       next_key_seq_num_ = seq_num + 1;
              :     }
> next_key_seq_num_ = std::max(next_key_seq_num_, seq_num + 1)
Done


PS10, Line 127:   tsk_deque_.clear();
              :   for (int i = 0; i < 2; ++i) {
              :     auto it = tsk_by_seq.begin();
              :     if (it != tsk_by_seq.end()) {
              :       tsk_deque_.emplace_back(it->second.release());
              :       tsk_by_seq.erase(tsk_by_seq.begin());
              :     }
              :   }
> hrm, could this be written more simply as:
Sure, that's much better.  Probably, that was too late in night -- that's why such crappy piece of code.


Line 139: Status TokenSigner::GenerateAuthnToken(string username,
> I still think we're going to end up refactoring this back into an AuthnToke
ok, sgtm


Line 152:   lock_guard<RWMutex> l(lock_);
> this can be a shared_lock, right? otherwise we are serializing signatures
Good catch.  Will fix.


Line 164:   lock_guard<RWMutex> l(lock_);
> can be shared
Done


Line 177:   lock_guard<RWMutex> l(lock_);
> I think this could work with just the read lock, with the exception of the 
yep, need to protect next_key_seq_num_.  I'll move the RSA key generation out from the lock.

Sequence number gap is not an issue, right.


Line 187:     return Status::OK();
> maybe returning Status::Aborted() or Status::AlreadyPresent() would be a cl
It seems you have been confused by the name of the method, sorry.

The interface is to return nullptr wrapped into unique_ptr in that case (need to return non-null in if a key is needed).  Non-OK status is reserved for other unexpected errors.  This helps to keep the call sites cleaner.

Also, the methods is renamed into CheckNeedKey()


http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS10, Line 63: TryPushKey
> name doesn't match impl
woops, sorry -- there have been 2 or 3 revisions of the TokenSigner interface.  I will fix this.


Line 113: //        RETURN_NOT_OK(ts.AddKey(std::move(key)));
> One thing that I think we should document in this class is whether it's OK 
Yep: holes in key sequence numbering is not an issue.  Every time you call CheckNeedKey() a new sequence number is assigned to the key output by the method, if any.

I will add a note about key sequence numbering.


PS10, Line 122: //    {
              : //      unique_ptr<TokenSigningPrivateKey> key;
              : //      RETURN_NOT_OK(ts.TryAddKey(&key));
              : //      if (key) {
              : //        // Store the newly generated key into the system table.
              : //        ...
              : //
              : //        // Add the key into the queue of the TokenSigner.
              : //        RETURN_NOT_OK(ts.AddKey(std::move(key)));
              : //      }
              : //    }
              : //    // Check and switch to the next key, if it's time.
              : //    RETURN_NOT_OK(ts.TryRotateKey());
> this is the exact same sequence as we have above, isn't it? I think it woul
Yep, eventually this ended up like this (and I think it's good).  Thank you for pointing at this.


PS10, Line 153: eximine
> typo
Done


PS10, Line 158: TryAddKey
> per comments elsewhere, I think a better name for this might be something l
Yep, good point.  How about CheckNeedKey ?


Line 188:   std::unique_ptr<TokenVerifier> verifier_;
> I think the single-ownership model here is going to be a little problematic
Yep, that's a point to discuss.  From one side, in the case of the master I'd prefer to not allow any other component modify state of TokenVerifier because of concerns over consistency of key sequence numbers.


Line 197:   std::deque<std::unique_ptr<TokenSigningPrivateKey>> tsk_deque_;
> add a doc here? which one is the current one? the head of the queue?
Done


http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_verifier.h
File src/kudu/security/token_verifier.h:

PS10, Line 53:   static const int64_t kPreStartSeqNum;
> doc
Done


PS10, Line 60: kPreStartSeqNum
> is the constant for this actually helping clarity or obfuscating it?
I just needed a constant to refer to as a parameter by default in ExportKeys and also in various test scenarios for validation of the key sequence numbers.

Do you mean it's better just drop this and go with some implicit constant like 0 or -1?  Would it help to add clarity?


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 10
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 14:

> Todd and I just discussed this offline.  Looks like the best route is to make a virtual method getters for the TokenVerifier on ServerBase, and then master can implement those through the TokenSigner, and tserver can implement them through a new TokenVerifier field.  The existing TokenVerifier field on ServerBase can be removed.

I'm looking at this a bit more trying to hook up everything together. I don't think the virtual method thing works as is, because ServerBase doesn't have the TokenVerifier, Messenger does. As much as shared ownership is often a kludge, I think a shared_ptr<TokenVerifier> shared by the signer and the messenger is the way to go. I'll try that at least as a quick solution.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 14
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 13:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/5930/13/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS13, Line 100:     // If it's past the key's activity period, it's too late to use it
              :     // for signing: do not consider it as an active key candidate.
              :  
> no need to change this, but I wonder whether we should still consider it, e
Good point. Let's keep it safe, I'm reverting this back.


PS13, Line 107:     // The criterion is:
              :     //   (expire_time - validity_interval) + 2 * rotation_interval <= now
              :     //
              :  
> nit: no need to duplicate the contents of the below statement
Done


PS13, Line 191:   // The criterion is:
              :   //   (expire_time - validity_interval) + rotation_interval <= now
              :  
> nit: this is just repeating what's in the code just below
Done


Line 252:   //   (expire_time - validity_interval) + 2 * rotation_interval <= now
> same
Done


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 13
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] WIP [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#4).

Change subject: WIP [security] tailored TokenSigner for system catalog
......................................................................

WIP [security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey(), storing the public part of the newly generated
key into the system table and then SetSigningKey().
That's also the sequence to be exercised by a master server upon becoming
a leader.  It's possible to run this sequence multiple times
on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/authn_token_manager.cc
M src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
8 files changed, 390 insertions(+), 108 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/4
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 4
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] WIP [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has uploaded a new patch set (#2).

Change subject: WIP [security] tailored TokenSigner for system catalog
......................................................................

WIP [security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation to loading
public part of token signing keys from the system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of Init().
That's the sequence to be exercised by a master server upon becoming
a leader.  It's possible to run this sequence multiple times
on the same instance of TokenSigner, generating new signing keys
only when already existing signing keys are about to expire.

Also, the TokenSigner class now embeds the logic to rotate its
signing key on Init(), if necessary.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/security/token-test.cc
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
5 files changed, 302 insertions(+), 50 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/2
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 10:

(22 comments)

Looks pretty good, mostly relatively small comments around clarity

http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/master/master.cc
File src/kudu/master/master.cc:

PS10, Line 116:                         FLAGS_token_signing_key_validity_seconds,
              :                                       FLAGS_token_signing_key_rotation_seconds,
              :                                       FLAGS_token_signing_key_propagation_seconds));
              :  
nit: weird indentation


PS10, Line 124:     RETURN_NOT_OK(token_signer_->TryAddKey(&key));
              :     if (key) {
              :       RETURN_NOT_OK(token_signer_->AddKey(std::move(key)));
this looks kind of strange to me. If "TryAddKey" succeeds, then why are we calling AddKey? Maybe 'TryAddKey' should be called something else that doesn't imply that it is adding it?

(haven't yet looked at the header docs for these functions, but from usage it's not intuitive)


http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS10, Line 56: DEFINE_int64(token_signing_key_rotation_seconds, 60 * 60 * 24 * 6,
             :              "number of seconds prior of the expiration time of current "
             :              "signing key when next key should be activated");
             : T
this config seems a bit "backwards" to me. I would expect if I set this to "1 day" then my key would rotate once a day. But in fact I have to set it to 6 days to get it to rotate once a day.


PS10, Line 51: DEFINE_int64(token_signing_key_validity_seconds, 60 * 60 * 24 * 7,
             :              "number of seconds that a token signing key is valid for");
             : TAG_FLAG(token_signing_key_validity_seconds, advanced);
             : TAG_FLAG(token_signing_key_validity_seconds, experimental);
             : 
             : DEFINE_int64(token_signing_key_rotation_seconds, 60 * 60 * 24 * 6,
             :              "number of seconds prior of the expiration time of current "
             :              "signing key when next key should be activated");
             : TAG_FLAG(token_signing_key_rotation_seconds, advanced);
             : TAG_FLAG(token_signing_key_rotation_seconds, experimental);
             : 
             : DEFINE_int64(token_signing_key_propagation_seconds, 60,
             :              "time necessary to propagate public part of TSK "
             :              "via tserver-to-master heartbeats with some margin");
             : TAG_FLAG(token_signing_key_propagation_seconds, advanced);
             : TAG_FLAG(token_signing_key_propagation_seconds, experimental);
I think these should be defined in master.cc where they're used - was surprised to find them here even though they aren't referenced in this .cc file.

Also keep in mind that the security/ module ends up exported into Impala (because it's a dependency of KRPC) so we should try to avoid Kudu-specific terminology in flag docs. Since you're now passing them in as constructor arguments, though, it'll be fine to move these flags to master.cc and keep the docs more or less as is (Kudu-specific)


PS10, Line 89: // Reload the TSKs (presumably originated from the system catalog table).
             : // This method can be called multiple times.
this doc should probably be in the header, not on the impl.

Also I think if it can be called multiple times we shouldn't call it 'Init' but rather 'LoadKeys' or something. Our convention is that Init methods must be called exactly once, and can't be concurrent with other access.


PS10, Line 91:  &k
nit: & goes with type


PS10, Line 111:     if (next_key_seq_num_ <= seq_num) {
              :       // Advance the key sequence number, if needed.
              :       next_key_seq_num_ = seq_num + 1;
              :     }
next_key_seq_num_ = std::max(next_key_seq_num_, seq_num + 1)


PS10, Line 127:   tsk_deque_.clear();
              :   for (int i = 0; i < 2; ++i) {
              :     auto it = tsk_by_seq.begin();
              :     if (it != tsk_by_seq.end()) {
              :       tsk_deque_.emplace_back(it->second.release());
              :       tsk_by_seq.erase(tsk_by_seq.begin());
              :     }
              :   }
hrm, could this be written more simply as:

tsk_deque_.clear();
for (auto& e : tsk_by_seq) {
  tsk_deque_.emplace_back(std::move(e.second));
}

(we already know that tsk_by_seq is max 2, right? and no need to erase the entries from that map since we're about to destruct it anyway)


Line 139: Status TokenSigner::GenerateAuthnToken(string username,
I still think we're going to end up refactoring this back into an AuthnTokenManager that lives in master/ at some point, but we can cross that bridge when we come to it.


Line 152:   lock_guard<RWMutex> l(lock_);
this can be a shared_lock, right? otherwise we are serializing signatures


Line 164:   lock_guard<RWMutex> l(lock_);
can be shared


Line 177:   lock_guard<RWMutex> l(lock_);
I think this could work with just the read lock, with the exception of the next_key_seq_num_ update. But I think it would be fine to acquire the sequence number "up front" under the write lock, or use an atomic for it, since we seem to be OK with potential sequence number gaps.

(keep in mind that the RSA key generation is expensive, and that clients would be blocked if you hold the write lock here)


Line 187:     return Status::OK();
maybe returning Status::Aborted() or Status::AlreadyPresent() would be a clearer way to express that there's no new key necessary?


http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS10, Line 63: TryPushKey
name doesn't match impl


Line 113: //        RETURN_NOT_OK(ts.AddKey(std::move(key)));
One thing that I think we should document in this class is whether it's OK for there to be "holes" in the sequence numbers. For example, what if you do TryAddKey() and then you time out while adding it to the system table. Then you don't actually know whether it was added or not. When you call TryAddKey() again later, are you going to get a higher sequence number or the same one again? If the former, then you might have a gap in sequence numbers (which I think is probably fine). If the latter, we might have an issue when we then try to store it again and get a duplicate key error.

I think my preference is to specify that there could always be gaps in sequence numbers (and I think the rest of the code handles it just fine)


PS10, Line 122: //    {
              : //      unique_ptr<TokenSigningPrivateKey> key;
              : //      RETURN_NOT_OK(ts.TryAddKey(&key));
              : //      if (key) {
              : //        // Store the newly generated key into the system table.
              : //        ...
              : //
              : //        // Add the key into the queue of the TokenSigner.
              : //        RETURN_NOT_OK(ts.AddKey(std::move(key)));
              : //      }
              : //    }
              : //    // Check and switch to the next key, if it's time.
              : //    RETURN_NOT_OK(ts.TryRotateKey());
this is the exact same sequence as we have above, isn't it? I think it would suffice to say that, at startup after loading existing keys, you should always immediately then check if it's also time to rotate the key (because you may have been down for a while or whatever).


PS10, Line 153: eximine
typo


PS10, Line 158: TryAddKey
per comments elsewhere, I think a better name for this might be something like GenerateNewKeyIfNeeded() or MaybeGenerateNewKey() since it isn't actually trying to _add_ the key.


Line 188:   std::unique_ptr<TokenVerifier> verifier_;
I think the single-ownership model here is going to be a little problematic with the way that Dan's integrating TokenVerifier with the RPC layer. We should figure out the plan to resolve this.


Line 197:   std::deque<std::unique_ptr<TokenSigningPrivateKey>> tsk_deque_;
add a doc here? which one is the current one? the head of the queue?


http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_verifier.h
File src/kudu/security/token_verifier.h:

PS10, Line 53:   static const int64_t kPreStartSeqNum;
doc


PS10, Line 60: kPreStartSeqNum
is the constant for this actually helping clarity or obfuscating it?


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 10
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#12).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading/storing TSKs
(Token Signing Keys) in system catalog.

The expected use-case for the TokenSigner is calling ImportKey() on
elected-as-leader callback with entries loaded from the system catalog
table, and then calling CheckNeedKey()/AddKey(), TryRotateKey() sequence.
Further down the road, it's necessary to call the CheckNeedKey()/AddKey(),
TryRotateKey() sequence periodically to generate and activate new TSKs.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
14 files changed, 796 insertions(+), 331 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/12
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 12
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 19: Code-Review+2

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 19
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 17:

> I put up a separate patch here: http://gerrit.cloudera.org:8080/6075
 > (on top of this one) which does the above shared_ptr thing. It's
 > not the prettiest but it works! able to connect via token to the
 > cluster in Java now.

OK, this sounds good to me.  So, we need to submitting those in right sequence :)  Anyway, we can re-base some patches, if needed.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 17
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#11).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey().  Then, the public part of the newly generated
TSK is stored into the system table.  If the data successfully stored,
call SetSigningKey() to set the newly generated TSK as TokenSigner's
signing key.  That's also the sequence to be exercised by a master
server upon becoming a leader.  It's possible to run this sequence
multiple times on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
14 files changed, 794 insertions(+), 328 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/11
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 11
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#9).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey().  Then, the public part of the newly generated
TSK is stored into the system table.  If the data successfully stored,
call SetSigningKey() to set the newly generated TSK as TokenSigner's
signing key.  That's also the sequence to be exercised by a master
server upon becoming a leader.  It's possible to run this sequence
multiple times on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
14 files changed, 708 insertions(+), 302 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/9
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 9
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 11:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/5930/11/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS11, Line 103: //   propagation interval: 1 day
> That's the timings of the original diagram.  I thought it's worth introduci
yea, I think fewer parameters is better unless there's some compelling reason someone would want to customize it. IIRC Hadoop does set rotation and propagation the same.


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 11
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#7).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey().  Then, the public part of the newly generated
TSK is stored into the system table.  If the data successfully stored,
call SetSigningKey() to set the newly generated TSK as TokenSigner's
signing key.  That's also the sequence to be exercised by a master
server upon becoming a leader.  It's possible to run this sequence
multiple times on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/authn_token_manager.cc
M src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
8 files changed, 359 insertions(+), 108 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/7
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 7
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 11:

(6 comments)

http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

Line 62:     int64_t key_pre_exp_rotation_seconds,
> In essence we need to make sure that the public part of the new key appears
hm, just saw Dan's comment after writing basically the same comment. I still think we could simplify and just use rotation = propagation interval. Otherwise there are a lot of constraints to think about (eg rotation interval must be greater than propagation interval)


http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

Line 188:   //
> Yep, that's a point to discuss.  From one side, in the case of the master I
yea, I think the RPC layer would be treating it read-only (just to verify tokens)


http://gerrit.cloudera.org:8080/#/c/5930/11/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS11, Line 50: assigned
nit: assigned a


PS11, Line 103: //   propagation interval: 1 day
it's a bit odd that propagation = rotation interval in this diagram. Although come to think of it, I'm not entirely sure what the propagation interval is for -- could we get rid of it and just always set propagation interval = rotation interval? I think that was the original design described in this comment, and I don't see any reason to need to customize it, but maybe I'm missing something


PS11, Line 118: perios
typo


PS11, Line 223: indended
typo: intended


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 11
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#13).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading/storing TSKs
(Token Signing Keys) in system catalog.

The expected use-case for the TokenSigner is calling ImportKey() on
elected-as-leader callback with entries loaded from the system catalog
table, and then calling CheckNeedKey()/AddKey(), TryRotateKey() sequence.
Further down the road, it's necessary to call the CheckNeedKey()/AddKey(),
TryRotateKey() sequence periodically to generate and activate new TSKs.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master-test.cc
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
15 files changed, 798 insertions(+), 332 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/13
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 13
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 14: Code-Review+2

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 14
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 17:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

Line 97:       RETURN_NOT_OK(verifier_->ImportKeys({ public_key_pb }));
> I don't think it's worth adding a method just for this case.  Batching keys
Ok, then how about changing ImportKeys to ImportKey and taking just one key at a time?


Line 168:     // It does not make much sense to keep more than two keys in the queue.
> Try to think of that the following way:
Ok I think I was missing the critical 2 keys in the queue piece.  Let's go with it as is.


Line 176:     return Status::OK();
> Interesting.  To me it's much easier to look at that in the absolute time s
The current R17 version looks great to me.


http://gerrit.cloudera.org:8080/#/c/5930/17/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS17, Line 48: n
Capitalize


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 17
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 10:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/5930/10/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

Line 62: DEFINE_int64(token_signing_key_propagation_seconds, 60,
I'm a little confused by this flag.  Shouldn't we just check that tsk_validity_seconds > 2 * tsk_rotation_seconds, and then rotate every tsk_rotation_seconds?  Or let me ask another way, how does this propagation_seconds amount relate to the block comment in the header?


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 10
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] WIP [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#6).

Change subject: WIP [security] tailored TokenSigner for system catalog
......................................................................

WIP [security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey(), storing the public part of the newly generated
key into the system table and then SetSigningKey().
That's also the sequence to be exercised by a master server upon becoming
a leader.  It's possible to run this sequence multiple times
on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/client/client-test.cc
M src/kudu/master/authn_token_manager.cc
M src/kudu/master/authn_token_manager.h
M src/kudu/master/master-test.cc
M src/kudu/master/master.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
10 files changed, 359 insertions(+), 110 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/6
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 6
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Todd Lipcon, Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#16).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading/storing TSKs
(Token Signing Keys) in system catalog.

The expected use-case for the TokenSigner is calling ImportKey() on
elected-as-leader callback with entries loaded from the system catalog
table, and then calling CheckNeedKey()/AddKey(), TryRotateKey() sequence.
Further down the road, it's necessary to call the CheckNeedKey()/AddKey(),
TryRotateKey() sequence periodically to generate and activate new TSKs.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master-test.cc
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/rpc/negotiation-test.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
M src/kudu/tserver/heartbeater.cc
17 files changed, 787 insertions(+), 334 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/16
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 16
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Todd Lipcon, Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#17).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading/storing TSKs
(Token Signing Keys) in system catalog.

The expected use-case for the TokenSigner is calling ImportKey() on
elected-as-leader callback with entries loaded from the system catalog
table, and then calling CheckNeedKey()/AddKey(), TryRotateKey() sequence.
Further down the road, it's necessary to call the CheckNeedKey()/AddKey(),
TryRotateKey() sequence periodically to generate and activate new TSKs.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master-test.cc
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/rpc/negotiation-test.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
M src/kudu/tserver/heartbeater.cc
17 files changed, 795 insertions(+), 334 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/17
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 17
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Todd Lipcon, Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#19).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading/storing TSKs
(Token Signing Keys) in system catalog.

The expected use-case for the TokenSigner is calling ImportKey() on
elected-as-leader callback with entries loaded from the system catalog
table, and then calling CheckNeedKey()/AddKey(), TryRotateKey() sequence.
Further down the road, it's necessary to call the CheckNeedKey()/AddKey(),
TryRotateKey() sequence periodically to generate and activate new TSKs.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master-test.cc
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/rpc/negotiation-test.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
M src/kudu/tserver/heartbeater.cc
17 files changed, 801 insertions(+), 334 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/19
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 19
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 14:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/master/master.h
File src/kudu/master/master.h:

Line 132:   std::unique_ptr<security::TokenSigner> token_signer_;
Checkout server_base.h, it's grown a TokenVerifier field.  In the master, we'll want to use the TokenVerifier internal to this TokenSigner, while on the tablet server, we'll want to use a standalone one.  Not sure the best way to do that, but it needs to be solved, otherwise the RPC system on the master won't be able to verify tokens.


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 14
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 7:

> > Good observation.  As I understand, AuthnTokenManager was modeled
 > to run along with MasterCertAuthority.  Besides aggregating
 > TokenSigner, it has just one additional perk of combining the code
 > which outputs signed Token.  We can safely move that code into the
 > TokenSigner itself.  I'm not aware of future plans to add some
 > extra functionality into the AuthTokenManager.
 > 
 > 
 > The reason to have it separate is that we'll sooner or later have
 > Authz tokens as well, which can reuse the same TokenSigner code,
 > but will probably have significantly different logic for what
 > material goes into the token. I'm not sure whether we'd want to
 > have different TSKs for authz vs authn -- it's probable that the
 > tokens would have a shorter lifetime, but not sure if the TSKs
 > should have different rotation periods, etc. Anyway, separating
 > them also makes the code more reusable and testable IMO.

Sounds good to me.  We discussed that with Dan over the Slack channel and I was going to make AuthnTokenManager aggregating TokenVerifier as well, keeping track of sequence numbers when importing public parts of keys from the system table (so, keeping the public TSK parts in TokenVerifier only).

However, after discussion of lock-related issues of the subsequent patch I'll change that a little bit different.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 7
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] WIP [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#5).

Change subject: WIP [security] tailored TokenSigner for system catalog
......................................................................

WIP [security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey(), storing the public part of the newly generated
key into the system table and then SetSigningKey().
That's also the sequence to be exercised by a master server upon becoming
a leader.  It's possible to run this sequence multiple times
on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/authn_token_manager.cc
M src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
8 files changed, 358 insertions(+), 108 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/5
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 5
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 7:

(3 comments)

I have some high level questions about the direction of TokenSigner and AuthnTokenManager.

Why is the TokenSigner holding all of the previous TSK public keys?  I wouldn't expect a class called 'TokenSigner' to need anything except a single private key and the current sequence number.  I realize that something in the master will need to track of the TSK public keys, but that's true of the tserver as well (which ostensibly won't have a TokenSigner), so I don't see why it should be in the TokenSigner.

Right now AuthnTokenManager is just a thin wrapper around TokenSigner.  Is it pulling its weight?  Are we planning to add more responsibilities to AuthnTokenManager in the future which would make it more than just a wrapper?

http://gerrit.cloudera.org:8080/#/c/5930/7/src/kudu/security/token-test.cc
File src/kudu/security/token-test.cc:

Line 278:   // The there should be 2 public keys exported.
remove 'The'


http://gerrit.cloudera.org:8080/#/c/5930/7/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

Line 43: // TODO(PKI): add flag tags
duplicate TODO


http://gerrit.cloudera.org:8080/#/c/5930/7/src/kudu/security/token_signer.h
File src/kudu/security/token_signer.h:

PS7, Line 91: CheckGenerateNewSigningKey
Should this be GenerateSigningKey?


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 7
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 11:

> Also may want to rebase on https://gerrit.cloudera.org/#/c/5988/

woops, missed that comment.  I will re-base later tonight.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 11
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 14:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/5930/14/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

Line 97:       RETURN_NOT_OK(verifier_->ImportKeys({ public_key_pb }));
> Ok, then how about changing ImportKeys to ImportKey and taking just one key
After some consideration I found it's not that hard to accumulate public parts of the keys and then import them in a batch manner.


Line 168:   const auto* key = tsk_deque_.front().get();
> Ok I think I was missing the critical 2 keys in the queue piece.  Let's go 
sgtm


Line 176:   if (key->expire_time() - key_validity_seconds_ + key_rotation_seconds_ <=
> The current R17 version looks great to me.
All right, then let's keep that R17 version.


http://gerrit.cloudera.org:8080/#/c/5930/17/src/kudu/security/token_signer.cc
File src/kudu/security/token_signer.cc:

PS17, Line 48: n
> Capitalize
Done


-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 14
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 10:

Also may want to rebase on https://gerrit.cloudera.org/#/c/5988/

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 10
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 7:

> (3 comments)

Thank you for the review. 

 > I have some high level questions about the direction of TokenSigner
 > and AuthnTokenManager.
 > 
 > Why is the TokenSigner holding all of the previous TSK public keys?
 >  I wouldn't expect a class called 'TokenSigner' to need anything
 > except a single private key and the current sequence number.

Right, that's the only things it needs.  I had a though to put the public parts of the keys into the pairing TokenVerifier or something like that, but that would require re-doing current scheme of TokenSigner/TokenVerifier.  I agree it would be a cleaner approach.

 > I realize that something in the master will need to track of the TSK
 > public keys, but that's true of the tserver as well (which
 > ostensibly won't have a TokenSigner), so I don't see why it should
 > be in the TokenSigner.

Yes, and that's already taken care of by TokenVerifier -- Todd added those two classes some time ago.  Take a look at src/kudu/security/token-test.cc to see the intended usage of those.

 > 
 > Right now AuthnTokenManager is just a thin wrapper around
 > TokenSigner.  Is it pulling its weight?  Are we planning to add
 > more responsibilities to AuthnTokenManager in the future which
 > would make it more than just a wrapper?

Good observation.  As I understand, AuthnTokenManager was modeled to run along with MasterCertAuthority.  Besides aggregating TokenSigner, it has just one additional perk of combining the code which outputs signed Token.  We can safely move that code into the TokenSigner itself.  I'm not aware of future plans to add some extra functionality into the AuthTokenManager.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 7
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5930

to look at the new patch set (#10).

Change subject: [security] tailored TokenSigner for system catalog
......................................................................

[security] tailored TokenSigner for system catalog

Updated the TokenSigner class in preparation for loading
and storing public part of token signing keys from/to system catalog.

The expected use-case for the TokenSigner is calling
AddTokenSigningPublicKey() multiple times while loading public part
of TSKs from the system catalog and subsequent call of
GenerateSigningKey().  Then, the public part of the newly generated
TSK is stored into the system table.  If the data successfully stored,
call SetSigningKey() to set the newly generated TSK as TokenSigner's
signing key.  That's also the sequence to be exercised by a master
server upon becoming a leader.  It's possible to run this sequence
multiple times on the same instance of TokenSigner.

Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
---
M src/kudu/master/CMakeLists.txt
D src/kudu/master/authn_token_manager.cc
D src/kudu/master/authn_token_manager.h
M src/kudu/master/master.cc
M src/kudu/master/master.h
M src/kudu/master/master_service.cc
M src/kudu/security/token-test.cc
M src/kudu/security/token.proto
M src/kudu/security/token_signer.cc
M src/kudu/security/token_signer.h
M src/kudu/security/token_signing_key.cc
M src/kudu/security/token_signing_key.h
M src/kudu/security/token_verifier.cc
M src/kudu/security/token_verifier.h
14 files changed, 718 insertions(+), 304 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/30/5930/10
-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 10
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] [security] tailored TokenSigner for system catalog

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: [security] tailored TokenSigner for system catalog
......................................................................


Patch Set 7:

> Good observation.  As I understand, AuthnTokenManager was modeled to run along with MasterCertAuthority.  Besides aggregating TokenSigner, it has just one additional perk of combining the code which outputs signed Token.  We can safely move that code into the TokenSigner itself.  I'm not aware of future plans to add some extra functionality into the AuthTokenManager.


The reason to have it separate is that we'll sooner or later have Authz tokens as well, which can reuse the same TokenSigner code, but will probably have significantly different logic for what material goes into the token. I'm not sure whether we'd want to have different TSKs for authz vs authn -- it's probable that the tokens would have a shorter lifetime, but not sure if the TSKs should have different rotation periods, etc. Anyway, separating them also makes the code more reusable and testable IMO.

-- 
To view, visit http://gerrit.cloudera.org:8080/5930
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2417e2ccba6a1114db366b2f642f95362bf479c
Gerrit-PatchSet: 7
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No