You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by sm...@apache.org on 2021/03/15 01:39:29 UTC
[knox] branch master updated: KNOX-2552 - Including the generated
Token ID in the JSON response for the KnoxToken service (#415)
This is an automated email from the ASF dual-hosted git repository.
smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new 4906682 KNOX-2552 - Including the generated Token ID in the JSON response for the KnoxToken service (#415)
4906682 is described below
commit 4906682f2f0b316bb6d2ddc102959df5eedeeddd
Author: Sandor Molnar <sm...@cloudera.com>
AuthorDate: Mon Mar 15 02:39:19 2021 +0100
KNOX-2552 - Including the generated Token ID in the JSON response for the KnoxToken service (#415)
---
.../java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java | 2 ++
.../apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java | 2 ++
2 files changed, 4 insertions(+)
diff --git a/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java b/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
index 3e20900..065cb93 100644
--- a/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
+++ b/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
@@ -69,6 +69,7 @@ public class TokenResource {
private static final String EXPIRES_IN = "expires_in";
private static final String TOKEN_TYPE = "token_type";
private static final String ACCESS_TOKEN = "access_token";
+ private static final String TOKEN_ID = "token_id";
private static final String TARGET_URL = "target_url";
private static final String ENDPOINT_PUBLIC_CERT = "endpoint_public_cert";
private static final String BEARER = "Bearer";
@@ -408,6 +409,7 @@ public class TokenResource {
HashMap<String, Object> map = new HashMap<>();
map.put(ACCESS_TOKEN, accessToken);
+ map.put(TOKEN_ID, tokenId);
map.put(TOKEN_TYPE, BEARER);
map.put(EXPIRES_IN, expires);
if (tokenTargetUrl != null) {
diff --git a/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java b/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java
index 9a5212d..9f27ef9 100644
--- a/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java
+++ b/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java
@@ -198,6 +198,8 @@ public class TokenServiceResourceTest {
String expiry = getTagValue(retString, "expires_in");
assertNotNull(expiry);
+ assertNotNull(getTagValue(retString, "token_id"));
+
// Verify the token
JWT parsedToken = new JWTToken(accessToken);
assertEquals("alice", parsedToken.getSubject());