Skip to content

Commit

Permalink
#211. Fixed with regression test. Tests for client credentials flow a…
Browse files Browse the repository at this point in the history
…dded.
  • Loading branch information
jjg-123 committed Oct 17, 2024
1 parent e8f5f8d commit 0d3af60
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 92 deletions.
65 changes: 22 additions & 43 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client-installer/buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Oct 15 05:53:26 CDT 2024
buildNumber\\d*=439
#Wed Oct 16 17:17:09 CDT 2024
buildNumber\\d*=443
4 changes: 2 additions & 2 deletions oa4mp-server-oauth2/buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Oct 15 05:52:22 CDT 2024
buildNumber\\d*=12364
#Wed Oct 16 17:16:46 CDT 2024
buildNumber\\d*=12366
68 changes: 35 additions & 33 deletions proxy/src/main/java/org/oa4mp/server/proxy/OA2ATServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,42 @@ Topography of the store. Auth grants (called temp_token for historical reasons)
}
break;
}
// Fix for https://github.com/ncsa/oa4mp/issues/211
// Needed to check exchange store in case multiple refreshes done at some point.
if (t == null) {
// if there is no such transaction found, then this is probably from a previous exchange. Go find it
try {
if (accessToken != null) {
t = OA2TokenUtils.getTransactionFromTX(oa2se, accessToken, debugger);
}
if (refreshToken != null) {
t = OA2TokenUtils.getTransactionFromTX(oa2se, refreshToken, debugger);
if (t != null) {
rfc8693Thingie.oldRTTX = (TXRecord) oa2se.getTxStore().get(refreshToken.getJTIAsIdentifier());
}
}
if (idToken != null) {
t = OA2TokenUtils.getTransactionFromTX(oa2se, idToken, debugger);
}
if (t != null) {
debugger.trace("found transaction from TX record.");
}

if (t != null) {
} catch (OA2GeneralError oa2GeneralError) {
if (!(debugger instanceof ClientDebugUtil)) {
// last ditch effort to tell us what client is doing this.
info("Could not find transaction for client " + client.getIdentifierString());
}
throw oa2GeneralError;
}
}

if (t == null) {
// Still null. Ain't one no place. Bail.
info("No pending transactions found anywhere for client \"" + client.getIdentifierString() + "\".");
throw new OA2ATException(OA2Errors.INVALID_GRANT, "no pending transaction found.", client);
}
if(!client.getIdentifierString().equals(t.getClient().getIdentifierString())){

debugger.trace(this, "transaction found, checking for ersatz client:" + t.summary());

Expand Down Expand Up @@ -1042,38 +1076,6 @@ Topography of the store. Auth grants (called temp_token for historical reasons)
}


if (t == null) {
// if there is no such transaction found, then this is probably from a previous exchange. Go find it
try {
if (accessToken != null) {
t = OA2TokenUtils.getTransactionFromTX(oa2se, accessToken, debugger);
}
if (refreshToken != null) {
t = OA2TokenUtils.getTransactionFromTX(oa2se, refreshToken, debugger);
if (t != null) {
rfc8693Thingie.oldRTTX = (TXRecord) oa2se.getTxStore().get(refreshToken.getJTIAsIdentifier());
}
}
if (idToken != null) {
t = OA2TokenUtils.getTransactionFromTX(oa2se, idToken, debugger);
}
if (t != null) {
debugger.trace("found transaction from TX record.");
}

} catch (OA2GeneralError oa2GeneralError) {
if (!(debugger instanceof ClientDebugUtil)) {
// last ditch effort to tell us what client is doing this.
info("Could not find transaction for client " + client.getIdentifierString());
}
throw oa2GeneralError;
}
}
if (t == null) {
// Still null. Ain't one no place. Bail.
info("No pending transactions found anywhere for client \"" + client.getIdentifierString() + "\".");
throw new OA2ATException(OA2Errors.INVALID_GRANT, "no pending transaction found.", client);
}
rfc8693Thingie.transaction = t;
if (client.isErsatzClient() && !client.isReadOnly()) {
// Gotten this far and there is an ersatz client. Read only is a good as "has been resolved"
Expand Down
4 changes: 2 additions & 2 deletions qdl/buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Oct 15 05:53:56 CDT 2024
buildNumber\\d*=13339
#Wed Oct 16 17:17:26 CDT 2024
buildNumber\\d*=13345
Binary file not shown.
Binary file added server-admin/src/main/docs/rfc6749_4_4.odt
Binary file not shown.
4 changes: 2 additions & 2 deletions server-installer/buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Oct 15 05:53:24 CDT 2024
buildNumber\\d*=437
#Wed Oct 16 17:17:07 CDT 2024
buildNumber\\d*=441
4 changes: 2 additions & 2 deletions server-test/buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Oct 15 05:52:24 CDT 2024
buildNumber\\d*=11400
#Wed Oct 16 17:16:47 CDT 2024
buildNumber\\d*=11402
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test.:= [
[path + 'auto/tests/' +'rtx_refreshes.qdl', initialization],
[path + 'auto/tests/' +'rtx.qdl',initialization],
[path + 'auto/tests/' +'revoke.qdl'],
[(path + 'auto/tests/rfc8693/') + 'github-211.qdl', '-subject','at'],
[(path + 'auto/tests/rfc8693/') + 'ersatz-rt.qdl', '-subject','at'],
[(path + 'auto/tests/rfc8693/') + 'ersatz-rt.qdl', '-subject','rt'],
[(path + 'auto/tests/rfc8693/') + 'ersatz-fork.qdl', '-at', '-subject','at'],
Expand Down
Loading

0 comments on commit 0d3af60

Please sign in to comment.