Add delegation feature to PKI realm#44106
Conversation
|
Pinging @elastic/es-security |
...ty/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthDelegationIntegTests.java
Show resolved
Hide resolved
bizybot
left a comment
There was a problem hiding this comment.
I am yet to finish my review, I am posting the comments where I think we need to discuss so
the conversation keeps going. Thank you.
...gin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/pki/PkiRealmSettings.java
Outdated
Show resolved
Hide resolved
...ugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/DelegatePkiRequest.java
Show resolved
Hide resolved
…ecurity/authc/pki/PkiRealm.java Co-Authored-By: Tim Vernum <tim@adjective.org>
| return false; | ||
| } | ||
| prevIssuer = cert.getIssuerX500Principal(); | ||
| } |
There was a problem hiding this comment.
I don't mind, but I would find this more readable as:
for (int i = 1; i < chain.length; i++) {
X509Certificate cert = chain[i-1];
X509Certificate issuer = chain[i];
if (false == cert.getIssuerX500Principal().equals(issuer.getSubjectX500Principal()) {
return false;
}
}
WDYT?
There was a problem hiding this comment.
LGTM, thanks for the suggestion!
|
|
||
| import java.util.Map; | ||
|
|
||
| public class TransportDelegatePkiAction extends HandledTransportAction<DelegatePkiRequest, DelegatePkiResponse> { |
There was a problem hiding this comment.
I feel as though this action (& the request/response) would be clearer with some variation on Authenticate in their name.
TransportDelegatedPkiAuthenticateActionTransportDelegatePkiAuthenticationActionTransportAuthenticateDelegatedPkiAction- ?
There was a problem hiding this comment.
TransportDelegatePkiAuthenticationAction sounds best to me. I'll go with that.
...curity/src/main/java/org/elasticsearch/xpack/security/action/TransportDelegatePkiAction.java
Outdated
Show resolved
Hide resolved
| } | ||
| prevIssuer = cert.getIssuerX500Principal(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Can we get rid of the duplication of this code (here and the action)?
CertParsingUtils would be an OK place for an isCertificateChainOrdered method.
There was a problem hiding this comment.
Thanks for suggesting CertParsingUtils !
|
I don't follow what's going on here with the feature branch... The development is being done directly on the main repo, and then we're proposing to merge it to I expected to see development on private branches, with PRs to merge into the feature branch on the main repo. |
Thank you, Tim, |
…ecurity/action/TransportDelegatePkiAction.java Co-Authored-By: Tim Vernum <tim@adjective.org>
|
@tvernum @bizybot I have addressed your reviews, please take another look :)
There is a story: The plan was to divide #43796 into several pieces. In order to do that, and have PRs based on one another (chained), PRs must be branches in the origin repo. Because the first piece #43932 was a bug fix, it was based on master, and this PR was based on that. When the bug fix had been merged, I should've picked Yogesh's branch, merge master, and re-target this PR to that; Instead I pointed this one to master by oversight, instead of creating a new branch. I have retargeted this to |
bizybot
left a comment
There was a problem hiding this comment.
Thank you for addressing the comments. It looks good, though we could add some tests (with different cert chains) that can be taken up later since we are working against the branch.
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertParsingUtils.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertParsingUtils.java
Outdated
Show resolved
Hide resolved
Co-Authored-By: Yogesh Gaikwad <902768+bizybot@users.noreply.github.com>
…ssl/CertParsingUtils.java Co-Authored-By: Yogesh Gaikwad <902768+bizybot@users.noreply.github.com>
|
@bizybot I'll add a test with a proper chain in a follow-up. |
bizybot
left a comment
There was a problem hiding this comment.
LGTM, Thank you, Albert, for the following up on comments.
We can add the tests for the cert chain checks in the next PR.
Introduces the
allow_delegationPKI Realm setting and theX509AuthenticationToken.isDelegatedproperty and puts them both at work insideTransportDelegatePkiActionto implement the exchange of a certificate chain for an ES access token, aka PKI delegation.If
allow_delegationistrue(defaultfalse) on a PKI realm then it will authenticateX509AuthenticationTokens created by theTransportDelegatePkiActionwhich have thedelegatedproperty set.It is a follow-up and hinges on #43932
Relates #34396