<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">The patch in question (#874) was not included in the 1.1.17 release because it has not been fully tested against all parts of the application and might just be delaying the issue in their instance instead of fixing the underlying problem.<div class=""><br class=""></div><div class="">&nbsp;— Justin</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 1, 2015, at 11:28 AM, Luiz Omori &lt;<a href="mailto:luiz.omori@duke.edu" class="">luiz.omori@duke.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">Hi Mark,</div>
<div class=""><br class="">
</div>
<div class="">Yes, indeed it is, and it looks like that was part of the 1.1.17 release, right?</div>
<div class=""><br class="">
</div>
<div class="">I’m not following exactly the logic behind the fix. Couldn’t we just have added a jti element to the ID token, similar to the access token? Or is this attribute not supposed to be there in this case?</div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Luiz</div>
<div class=""><br class="">
</div>
<span id="OLK_SRC_BODY_SECTION" class="">
<div style="font-family: Calibri; font-size: 11pt; text-align: left; border-width: 1pt medium medium; border-style: solid none none; padding: 3pt 0in 0in; border-top-color: rgb(181, 196, 223);" class="">
<span style="font-weight:bold" class="">From: </span>Mark Janssen &lt;<a href="mailto:callisto@praseodym.net" class="">callisto@praseodym.net</a>&gt;<br class="">
<span style="font-weight:bold" class="">Date: </span>Tuesday, September 1, 2015 at 11:16 AM<br class="">
<span style="font-weight:bold" class="">To: </span>Luiz Omori &lt;<a href="mailto:luiz.omori@dm.duke.edu" class="">luiz.omori@dm.duke.edu</a>&gt;, "<a href="mailto:mitreid-connect@mit.edu" class="">mitreid-connect@mit.edu</a>" &lt;<a href="mailto:mitreid-connect@mit.edu" class="">mitreid-connect@mit.edu</a>&gt;<br class="">
<span style="font-weight:bold" class="">Subject: </span>Re: [mitreid-connect] Exception during cleanup<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="ltr" class="">Hi Luiz,
<div class=""><br class="">
</div>
<div class="">Check out&nbsp;<a href="https://github.com/mitreid-connect/OpenID-Connect-Java-Spring-Server/issues/862" class="">https://github.com/mitreid-connect/OpenID-Connect-Java-Spring-Server/issues/862</a>, it seems to be exactly the problem you're having.</div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Mark</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Tue, 1 Sep 2015 at 16:50 Luiz Omori &lt;<a href="mailto:luiz.omori@duke.edu" class="">luiz.omori@duke.edu</a>&gt; wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap: break-word; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">OK, I managed to reproduce the problem: it’s related to duplicated ID tokens being created when multiple
<b class="">similar</b> requests are received within the same second.&nbsp; In our case we use the Resource Owner flow for some legacy web services calls and that exacerbates the problem. At some point the code does a select on the access_token table using the token_value
 column and checks for number of rows returned, enforcing 1.</div>
<div class=""><br class="">
</div>
<div class="">This token appears 38 times in the access_token table when we ran a stress test that makes 50 parallel Resource Owner requests (test environment):</div>
<div class=""><br class="">
</div>
<div class="">eyJraWQiOiJyc2ExIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA4MFwvbGRhcC1vcGVuaWQtY29ubmVjdC1zZXJ2ZXJcLyIsInN1YiI6IkNBVFNfZGFzaHNydiIsImF1ZCI6WyJncm93dGhfY2hhcnQiXSwiZXhwIjoxNDQxMTE0NTMzLCJpYXQiOjE0NDExMTQ0NzMsImtpZCI6InJzYTEifQ.NVSFBd9onhEUgMDC46KAJx5M_CaBy-INuy0MqodLqOCO7YQ5N9ZARG9BKemjv8G0Aj8aIYOa-CJeUYycv6Uk1qqVTcXX9jgpX7-f9xK4T4MxcOhhTwRqkvT8l7yWL5uAm1uG7lcKKHw6h2RGed4x9zej1Zb0PFiHTZHkPRl6OWwJvmaZySd0CZM3VVVtW4HIB45vNURE--ee5zkH1ezoJOfR0JlFFEaQfcTnW-PGBcNri6huk1fosUwLxoZE8-YGjwWVzKyy_1qmZBhS9Yg1ch6uXuxaXjG96_ITZQVoIyFwWyMi3rXOiwdgAzN_7aZOt8HSxNm7OUqFxZEr6JChbw</div>
<div class=""><br class="">
</div>
<div class="">The concern is the growth of that table and since at least in MySQL version the token_value is not indexed (we could fix it locally) potential slow down over time.</div>
<div class=""><br class="">
</div>
<div class="">Is there any workaround that we could use on our production system? Unfortunately, as opposed to my local system, our production environment is using HSSQLDB which most likely will prevent us from running delete SQL commands while the system is running.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Maybe we can add JTI to the ID tokens to make them unique?</div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Luiz</div>
<div class=""><br class="">
</div>
<span class="">
<div style="font-family: Calibri; font-size: 11pt; text-align: left; border-width: 1pt medium medium; border-style: solid none none; padding: 3pt 0in 0in; border-top-color: rgb(181, 196, 223);" class="">
<span style="font-weight:bold" class="">From: </span>Luiz Omori &lt;<a href="mailto:luiz.omori@dm.duke.edu" target="_blank" class="">luiz.omori@dm.duke.edu</a>&gt;<br class="">
<span style="font-weight:bold" class="">Date: </span>Monday, August 31, 2015 at 4:50 PM<br class="">
<span style="font-weight:bold" class="">To: </span>"<a href="mailto:mitreid-connect@mit.edu" target="_blank" class="">mitreid-connect@mit.edu</a>" &lt;<a href="mailto:mitreid-connect@mit.edu" target="_blank" class="">mitreid-connect@mit.edu</a>&gt;<br class="">
<span style="font-weight:bold" class="">Subject: </span>Exception during cleanup<br class="">
</div>
</span></div>
<div style="word-wrap: break-word; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<span class="">
<div class=""><br class="">
</div>
<div class="">
<div style="word-wrap: break-word; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">Hi,</div>
<div class=""><br class="">
</div>
<div class="">We have a system in production that is logging some exceptions. This is happening in DefaultOAuth2ProviderTokenService.clearExpiredTokens. I’ve been trying to track that down but so far no luck reproducing it on my development environment.&nbsp; Has anybody
 seem this? Is it benign or something we should be concerned about?&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">
<div class=""><span style="white-space:pre-wrap" class=""></span>@Override</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>public void clearExpiredTokens() {</div>
<div class=""><span style="white-space:pre-wrap" class=""></span><a href="http://logger.info/" target="_blank" class="">logger.info</a>("Cleaning out all expired tokens");</div>
<div class=""><br class="">
</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>Collection&lt;OAuth2AccessTokenEntity&gt; accessTokens = getExpiredAccessTokens();</div>
<div class=""><span style="white-space:pre-wrap" class=""></span><a href="http://logger.info/" target="_blank" class="">logger.info</a>("Found " + accessTokens.size() + " expired access tokens");</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>for (OAuth2AccessTokenEntity oAuth2AccessTokenEntity : accessTokens) {</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>try {</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>revokeAccessToken(oAuth2AccessTokenEntity);</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>} catch (IllegalArgumentException e) {</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>//An ID token is deleted with its corresponding access token, but then the ID token is on the list of expired tokens as well and there is</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>//nothing in place to distinguish it from any other.</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>//An attempt to delete an already deleted token returns an error, stopping the cleanup dead. We need it to keep going.</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>}</div>
<div class=""><span style="white-space:pre-wrap" class=""></span>}</div>
<div class="">…</div>
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">2015Aug27 16:38:49,564: ERROR: org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.</div>
<div class="">java.lang.IllegalStateException: Expected single result, got 2</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.mitre.util.jpa.JpaUtil.getSingleResult(JpaUtil.java:36)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository.getAccessTokenByValue(JpaOAuth2TokenRepository.java:62)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository.removeAccessToken(JpaOAuth2TokenRepository.java:79)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository$$FastClassBySpringCGLIB$$145026dd.invoke(&lt;generated&gt;)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository$$EnhancerBySpringCGLIB$$e7092f0b.removeAccessToken(&lt;generated&gt;)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.mitre.oauth2.service.impl.DefaultOAuth2ProviderTokenService.revokeAccessToken(DefaultOAuth2ProviderTokenService.java:380)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.mitre.oauth2.service.impl.DefaultOAuth2ProviderTokenService.clearExpiredTokens(DefaultOAuth2ProviderTokenService.java:411)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.util.concurrent.FutureTask.runAndReset(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; at java.lang.Thread.run(Unknown Source)</div>
</div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Luiz</div>
</div>
</div>
</span></div>
_______________________________________________<br class="">
mitreid-connect mailing list<br class="">
<a href="mailto:mitreid-connect@mit.edu" target="_blank" class="">mitreid-connect@mit.edu</a><br class="">
<a href="http://mailman.mit.edu/mailman/listinfo/mitreid-connect" rel="noreferrer" target="_blank" class="">http://mailman.mit.edu/mailman/listinfo/mitreid-connect</a><br class="">
</blockquote>
</div>
</div>
</div>
</div>
</span>
</div>

_______________________________________________<br class="">mitreid-connect mailing list<br class=""><a href="mailto:mitreid-connect@mit.edu" class="">mitreid-connect@mit.edu</a><br class="">http://mailman.mit.edu/mailman/listinfo/mitreid-connect<br class=""></div></blockquote></div><br class=""></div></body></html>