-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KNOX-2712 - Managing custom Knox Token metadata #542
Conversation
...service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
Outdated
Show resolved
Hide resolved
...service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
Outdated
Show resolved
Hide resolved
...xtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java
Outdated
Show resolved
Hide resolved
...xtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be i am misunderstanding, but using GET to add metadata seems odd.
As I understand it, you're GETting a token with the specified metadata. |
@pzampino - all of your review comments are addressed/fixed. Could you please take another look? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM...just a comment about a possible performance enhancement not directly related to these changes.
for (Map.Entry<String, String> entry : metadataMap.entrySet()) { | ||
if (StringUtils.isBlank(entry.getValue()) || "*".equals(entry.getValue())) { | ||
// we should only filter tokens by metadata name | ||
if (knoxToken.getMetadata().getMetadataMap().containsKey(entry.getKey())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily related to this change, but it seems to me that TokenMetadata could have a generic get(String key)
method, rather than requiring making a copy of the metadataMap
every time a value is needed to be looked up (knoxToken.getMetadata().getMetadataMap()
).
public String get(final String key) { return metadataMap.get(key); }
Such that lookups could be more simply knoxToken.getMetadata().get(key)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks for your time to review my changes.
Change-Id: I68b16236000dafda0ae627a98426d93948dca9d4
What changes were proposed in this pull request?
The following enhancements were added by this change:
GET
API is extended to handle custom metadata informationgetUserTokens
API endpoint is extended to filter tokens by metadata name/valueHow was this patch tested?
Adjusted and ran JUnit tests:
Additionally, I tested the API changes with the following
curl
commands:As you can see I tried to challenge the
GET
API withTokenStateDatabase
we usePreparedStatement
objects to communicate with the DB, so we are safe)I also tested the updated
getUserTokens
API: