Skip to content

Split internal client escalation from Authenticator interface#5073

Merged
jon-wei merged 3 commits intoapache:masterfrom
jon-wei:escalator
Nov 14, 2017
Merged

Split internal client escalation from Authenticator interface#5073
jon-wei merged 3 commits intoapache:masterfrom
jon-wei:escalator

Conversation

@jon-wei
Copy link
Copy Markdown
Contributor

@jon-wei jon-wei commented Nov 10, 2017

While developing an extension for basic HTTP authentication, I encountered the following problem:

The Authenticator implementation needed to communicate with the coordinator during initialization, grabbing data from an HTTP endpoint, using a DruidLeaderClient. This led to circular dependency issues as the DruidLeaderClient needs an escalated HTTP client created by an Authenticator to successfully authenticate with the coordinator.

This PR splits the "send requests with privileged internal system user credentials" functionality out of the Authenticator interface into a new Escalator interface, to help avoid circular dependency issues when Authenticator extension implementations need to communicate with Druid cluster nodes.

@gianm
Copy link
Copy Markdown
Contributor

gianm commented Nov 13, 2017

@jon-wei there's a conflict here now.

@jon-wei jon-wei added this to the 0.11.0 milestone Nov 13, 2017
@jon-wei
Copy link
Copy Markdown
Contributor Author

jon-wei commented Nov 13, 2017

I would like to get this into 0.11.0 as well, this isn't a "bug" but I think authenticator extension implementers are likely to run into similar circular dependency issues if they have intra-cluster communication requirements during authenticator initialization, and it would nice to have that addressed in the initial interface release

@jon-wei
Copy link
Copy Markdown
Contributor Author

jon-wei commented Nov 13, 2017

@gianm fixed conflict

Copy link
Copy Markdown
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

👍 LGTM.

final AuthConfig authConfig,
final AuthorizerMapper authorizerMapper,
final AuthenticatorMapper authenticatorMapper
final Escalator escalator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's cool that what's needed here got more fine grained.


for (String authenticator : authenticators) {
String typeProperty = StringUtils.format("druid.auth.authenticator.%s.type", authenticator);
if (escalatorType.equals(properties.getProperty(typeProperty))) {
Copy link
Copy Markdown
Contributor

@himanshug himanshug Nov 13, 2017

Choose a reason for hiding this comment

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

why is it required that escalatorType must match one of the Authenticator types ? Also, does this mean Escalator impls and Authenticator impls must have same json type names ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, I think this is a good question -- do we really need to require that escalators match up with an authenticator?

I think there's no reason they should need to match exactly. It's plausible that an escalator doesn't line up totally with an authenticator. Imagine that the authenticator is a standard RBAC authenticator, and the escalator is some custom extension that pulls the internal user password from somewhere more secure than a config file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whatever authentication scheme an Escalator uses, it has to be supported by some Authenticator that's configured, so I impose that type matching restriction to conceptually link the implementations.

It could function without that restriction, but I don't see much reason to have them differ.

This does mean they must have the same JSON type names, I have a section in the doc that calls out this requirement:

The Escalator chosen for this property must have the same type as an Authenticator in `druid.auth.authenticationChain. Authenticator extension implementors must also provide a corresponding Escalator implementation with the same type name if they intend to use a particular authentication scheme for internal Druid communications.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, so technically its not necessary but you're imposing the restriction so that user thinks about Escalator and Authenticator impl together.
I think it would help extension writers if we put some comment on both Authenticator and Escalator interfaces that implementers must ensure that both Escalator and Authenticator implementations must have exactly same json type name. Its easy to miss from that line in the doc alone. thanks.

Copy link
Copy Markdown
Contributor

@himanshug himanshug Nov 13, 2017

Choose a reason for hiding this comment

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

@gianm how did your comment do the time travel ? (it shows up as 2nd comment wherease it should be 4th comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:magic:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@himanshug @gianm I removed the type matching enforcement

* getEscalatedClient() method.
*/
public class AuthenticatorHttpClientWrapper
public class AllowAllEscalator implements Escalator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is more of "NoopEscalator" , but I think it is named that way to match name with corresponding Authenticator impl used on the target server.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

renamed this to "NoopEscalator"

Copy link
Copy Markdown
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

some additional comments.

{
String escalatorType = properties.getProperty("druid.escalator.type");
if (escalatorType == null) {
escalatorType = "allowAll";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be a constant (static final somewhere) and ideally all instances of the string "allowAll" would reference that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made "allowAll" a constant under AuthConfig


for (String authenticator : authenticators) {
String typeProperty = StringUtils.format("druid.auth.authenticator.%s.type", authenticator);
if (escalatorType.equals(properties.getProperty(typeProperty))) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, I think this is a good question -- do we really need to require that escalators match up with an authenticator?

I think there's no reason they should need to match exactly. It's plausible that an escalator doesn't line up totally with an authenticator. Imagine that the authenticator is a standard RBAC authenticator, and the escalator is some custom extension that pulls the internal user password from somewhere more secure than a config file.

@himanshug
Copy link
Copy Markdown
Contributor

👍 once #5073 (comment) is resolved .

Comment thread docs/content/configuration/auth.md Outdated
|--------|-----------|--------|--------|--------|
|`druid.auth.authenticationChain`|JSON List of Strings|List of Authenticator type names|["allowAll"]|no|
|`druid.escalator.type`|String|Type of the Escalator that should be used for internal Druid communications. This Escalator must have the same type as an Authenticator in `druid.auth.authenticationChain`.|"allowAll"|no|
|`druid.escalator.type`|String|Type of the Escalator that should be used for internal Druid communications. This Escalator must have the same type as an Authenticator in `druid.auth.authenticationChain`.|"noop"|no|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"This Escalator..." line is not correct anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

whoops, thanks

@jon-wei jon-wei merged commit 9ac150c into apache:master Nov 14, 2017
jon-wei added a commit to jon-wei/druid that referenced this pull request Nov 14, 2017
…#5073)

* Split internal client escalation from Authenticator interface

* PR comments
jon-wei added a commit that referenced this pull request Nov 14, 2017
…#5084)

* Split internal client escalation from Authenticator interface

* PR comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants