Skip to content

Commit

Permalink
SAK-32554 Fix OAuth_consumer_key check (sakaiproject#4438)
Browse files Browse the repository at this point in the history
Check the Authorization header for oauth_consumer_key if it is not a
parameter.
  • Loading branch information
master-bob authored and csev committed May 20, 2017
1 parent a64d97f commit afddc13
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,21 @@ protected void doPostForm(HttpServletRequest request, HttpServletResponse respon

String oauth_consumer_key = request.getParameter("oauth_consumer_key");
if(BasicLTIUtil.isBlank(oauth_consumer_key)) {
doError(request, response, theMap, "outcomes.missing", "oauth_consumer_key", null);
return;
// no parameter for key, check header
final String authorizationHeader = request.getHeader("authorization");
if(authorizationHeader.contains("oauth_consumer_key") ) {
String[] keys = authorizationHeader.split(",");
for(String key : keys) {
if(key.startsWith("oauth_consumer_key")) {
int end = key.length() - 1;
oauth_consumer_key = key.substring(20, end);
}
}
}
if(BasicLTIUtil.isBlank(oauth_consumer_key)) {
doError(request, response, theMap, "outcomes.missing", "oauth_consumer_key", null);
return;
}
}

// Truncate this to the maximum length to insure no cruft at the end
Expand Down

0 comments on commit afddc13

Please sign in to comment.