Skip to content

Commit 8011b31

Browse files
Clear Origin ThreadLocal after AuthN in ExternalOAuthAuthenticationManager (#3619)
* Add clearing of ThreadLocal after authentication * Wrap super.authenticate call in try-finally and move clearing of ThreadLocal to finally block
1 parent 8b25fc2 commit 8011b31

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

server/src/main/java/org/cloudfoundry/identity/uaa/provider/oauth/ExternalOAuthAuthenticationManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ public void setOrigin(String origin) {
178178
this.origin.set(origin);
179179
}
180180

181+
@Override
182+
public Authentication authenticate(final Authentication request) throws AuthenticationException {
183+
try {
184+
return super.authenticate(request);
185+
} finally {
186+
// clear ThreadLocal holding the origin key
187+
origin.remove();
188+
}
189+
}
190+
181191
public IdentityProvider resolveOriginProvider(String idToken) throws AuthenticationException {
182192
try {
183193
Map<String, Object> claims = parseClaimsFromIdTokenString(idToken);

0 commit comments

Comments
 (0)