Skip to content

Proxy forward auth data - #1169

Merged
jai1 merged 20 commits into
apache:masterfrom
jai1:ProxyForwardAuthData
Feb 8, 2018
Merged

Proxy forward auth data#1169
jai1 merged 20 commits into
apache:masterfrom
jai1:ProxyForwardAuthData

Conversation

@jai1

@jai1 jai1 commented Feb 2, 2018

Copy link
Copy Markdown
Contributor

======

Currently the proxy extracts and forwards the client Principal to the broker. Client Principal is a modifiable string i.e can be changed or manufactured by the Proxy.

What we want to do instead is to send the clientAuthData to the broker - which is in most cases digitally signed. The broker will extract the client principal from the clientAuthData and reauthenticate the client.

In order to enforce this behavior we have introduced two new flags:-

  • authenticateOriginalAuthData on the broker
  • forwardClientAuthData on the Proxy

======

@msb-at-yahoo

@jai1 jai1 added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Feb 2, 2018
@jai1 jai1 self-assigned this Feb 2, 2018

@saandrews saandrews left a 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.

Overall looks ok, few comments.

private final int MaxNonPersistentPendingMessages;
private String originalPrincipal = null;

private Set<String> proxyRoles = Sets.newHashSet();

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.

If it's initialized in constructor, why create a new set here?

ctx.close();
}

private boolean validateOriginalPrincipal(String originalPrincipal, ByteBuf errorResponse, String topicName,

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.

Can you add comment explaining the logic?

connect.hasOriginalAuthData() ? connect.getOriginalAuthData() : null,
connect.hasOriginalAuthMethod() ? connect.getOriginalAuthMethod() : null,
connect.hasOriginalPrincipal() ? connect.getOriginalPrincipal() : null,
sslSession);

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.

What happens if sslSession is null ?

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.

is sslSession is null AuthDataCommand.hasDataFromTls will return false


// Original auth role and auth Method that was passed
// to the proxy. In this case the auth info above
// will the the auth of the proxy itself

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.

"will be the"?

Same for the remaining comments as well.

@jai1

jai1 commented Feb 6, 2018

Copy link
Copy Markdown
Contributor Author

@saandrews - have addressed your comments
@rdhabalia @merlimat - Please review this PR when you find time

@jai1

jai1 commented Feb 6, 2018

Copy link
Copy Markdown
Contributor Author

retest this please

@merlimat merlimat mentioned this pull request Feb 6, 2018

// If this flag is set then the broker authenticates the original Auth data
// else it just accepts the originalPrincipal and authorizes it (if required).
private boolean authenticateOriginalAuthData = false;

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.

Config options need to be also added into conf/broker.conf and conf/standalone.conf, also check if there is a suitable name prefix this can be aggregated into.

if (lookupSemaphore.tryAcquire()) {
final String originalPrincipal = lookup.hasOriginalPrincipal() ? lookup.getOriginalPrincipal()
: this.originalPrincipal;
String originalPrincipal;

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 check can be done before acquiring the semaphore

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.

As with similar changes, try to put common logic in a single method


// Forward client authData to Broker for re authorization
// make sure authentication is enabled for this to take effect
private boolean forwardAuthData = false;

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.

Should be added to proxy.conf

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.

Rename to something like authorizationForwardCredentials or similar

@jai1

jai1 commented Feb 7, 2018

Copy link
Copy Markdown
Contributor Author

As with similar changes, try to put common logic in a single method

@merlimat - Have addressed your comments

I feel the last commit (f986185) addresses your comment but makes the logic more difficult to understand

@jai1

jai1 commented Feb 7, 2018

Copy link
Copy Markdown
Contributor Author

@merlimat @rdhabalia @saandrews - can I merge this or do you want to take one last look.

@rdhabalia rdhabalia left a 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.

overall LGTM..

lookup);

if (authenticateOriginalAuthData && lookup.hasOriginalAuthData() && originalPrincipal == null) {
return;

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 condition seems little tricky. if we fail to validate original principal then validateOriginalPrincipal() will send failure response to the client and then thread should not process anything further. but then with this condition there is a possibility to move forward and thread will do further processing if authenticateOriginalAuthData && lookup.hasOriginalAuthData() =is false.??

@jai1

jai1 commented Feb 8, 2018

Copy link
Copy Markdown
Contributor Author

@rdhabalia - handled your comments - hope to get a +1 from you

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

Labels

type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants