3. Principle of Least Privilege
Username:
Forgot Password
jzheaux OK
Sorry, we don’t recognize that username
Username:
Forgot Password
jzheaux OK
If that username exists, we’ve just sent an email
4. Request Thread Local
try {
SecurityContext ctx = lookup(request);
SecurityContextHolder.setContext(ctx);
chain.doFilter(request, response);
}
finally {
SecurityContextHolder.clearContext()
}
public void serviceLayerMethod() {
var ctx = SecurityContextHolder.getContext();
}
Stores data in a
ThreadLocal so only
visible to this thread
Clears data so
ThreadLocal can be
used for next request
Now data can be
retrieved at the service
layer
ForReactiveapps,use
theReactorContext
insteadofThreadLocals