Skip to content

Commit

Permalink
Merge pull request #1324 from AmaliMatharaarachchi/version_all
Browse files Browse the repository at this point in the history
Fix version * subscribed apis validation
  • Loading branch information
menakajl authored Jul 16, 2020
2 parents 9603fbd + cb2fe14 commit bd44eb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ public function getAPIDetails(jwt:JwtPayload payload, string apiName, string api
int index = 0;
while (index < l) {
var subscription = subscribedAPIList[index];
if (subscription.name.toString() == apiName && subscription.'version.toString() == apiVersion) {
if (subscription.name.toString() == apiName &&
(subscription.'version.toString() == apiVersion || subscription.'version.toString() == "*")) {
// API is found in the subscribed APIs
if (isDebugEnabled) {
printDebug(KEY_JWT_AUTH_PROVIDER, "Found the API in subscribed APIs:" + subscription.name.toString()
Expand All @@ -233,7 +234,7 @@ public function getAPIDetails(jwt:JwtPayload payload, string apiName, string api
apiDetails["apiName"] = subscription.name.toString();
}
if (subscription.'version is json) {
apiDetails["apiVersion"] = subscription.'version.toString();
apiDetails["apiVersion"] = apiVersion;
}
if (subscription.context is json) {
apiDetails["apiContext"] = subscription.context.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public function handleSubscribedAPIs(string apiKeyToken, jwt:JwtPayload payload,
int index = 0;
while (index < l) {
var subscription = subscribedAPIList[index];
if (subscription.name.toString() == apiName && subscription.'version.toString() == apiVersion) {
if (subscription.name.toString() == apiName &&
(subscription.'version.toString() == apiVersion || subscription.'version.toString() == "*")) {
// Successfully validated the API. Then set authenticated to true.
authenticationContext.authenticated = true;
if (isDebugEnabled) {
Expand Down Expand Up @@ -183,6 +184,7 @@ public function handleSubscribedAPIs(string apiKeyToken, jwt:JwtPayload payload,
index += 1;
}
}
printDebug(JWT_UTIL, "matching API is not found as subscribed API");
if (isDebugEnabled) {
printDebug(JWT_UTIL, "Set username : " + authenticationContext.username + ", keytype : "
+ authenticationContext.keyType + ", consumer key : " + authenticationContext.consumerKey
Expand Down

0 comments on commit bd44eb7

Please sign in to comment.