Skip to content

Commit

Permalink
Merge pull request #245 from Rajith90/master
Browse files Browse the repository at this point in the history
Workaround to handle expect header at micro-gw
  • Loading branch information
chamilaadhi authored Sep 14, 2018
2 parents 37954e1 + 2ac8edc commit a49bb37
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ service<http:Service> {{cut qualifiedServiceName " "}} bind {{#api.transport}}{{
}
@gateway:RateLimit{policy : "{{resourceTier}}"}
{{operationId}} (endpoint outboundEp, http:Request req) {
gateway:checkExpectHeaderPresent(req);
{{#if api.isDefaultVersion}}
string urlPostfix = untaint req.rawPath.replace("{{api.context}}","");
{{else}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
@final public string JWT_CONFIG_INSTANCE_ID = "jwtConfig";
@Description { value: "JWT header name"}
@final public string JWT_HEADER = "header";
@final public string EXPECT_HEADER = "Expect";

// end of config constants

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ service<http:Service> authorizeService bind tokenListenerEndpoint {
path: "/*"
}
authorizeResource(endpoint caller, http:Request req) {
checkExpectHeaderPresent(req);
var response = keyValidationEndpoint->forward(getConfigValue(KM_CONF_INSTANCE_ID, KM_TOKEN_CONTEXT, "/oauth2") +
untaint req.rawPath, req);
match response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ service<http:Service> revokeService bind tokenListenerEndpoint {
path: "/*"
}
revokeResource(endpoint caller, http:Request req) {
checkExpectHeaderPresent(req);
var response = keyValidationEndpoint->forward(getConfigValue(KM_CONF_INSTANCE_ID, KM_TOKEN_CONTEXT, "/oauth2") +
untaint req.rawPath, req);
match response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ service<http:Service> tokenService bind tokenListenerEndpoint {
path: "/*"
}
tokenResource(endpoint caller, http:Request req) {
checkExpectHeaderPresent(req);
var response = keyValidationEndpoint->forward(getConfigValue(KM_CONF_INSTANCE_ID, KM_TOKEN_CONTEXT, "/oauth2") +
untaint req.rawPath, req);
match response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ service<http:Service> userInfoService bind tokenListenerEndpoint {
path: "/*"
}
userInfoResource(endpoint caller, http:Request req) {
checkExpectHeaderPresent(req);
var response = keyValidationEndpoint->forward(getConfigValue(KM_CONF_INSTANCE_ID, KM_TOKEN_CONTEXT, "/oauth2") +
untaint req.rawPath, req);
match response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,11 @@ function checkOrSetMessageID(http:FilterContext context) {
context.attributes[MESSAGE_ID] = system:uuid();
}
}

public function checkExpectHeaderPresent(http:Request request) {
if (request.expects100Continue()) {
request.removeHeader(EXPECT_HEADER);
printDebug(KEY_UTILS, "Expect header is removed from the request");

}
}

0 comments on commit a49bb37

Please sign in to comment.