use of com.peterphi.std.guice.web.rest.scoping.SessionScoped in project stdlib by petergeneric.
the class WebappAuthenticationModule method getCurrentUser.
@Provides
@SessionScoped
public CurrentUser getCurrentUser(Injector injector, HttpServletRequest request) {
for (String providerName : providerNames) {
final Provider<CurrentUser> provider = injector.getProvider(Key.get(CurrentUser.class, Names.named(providerName)));
final CurrentUser user = provider.get();
if (user != null) {
// Store the user info for logging
if (user.getUsername() != null) {
MDC.put(TracingConstants.MDC_USER_ID, user.getUsername());
}
return user;
}
}
throw new IllegalArgumentException("No provider could determine a user for HTTP request!");
}
Aggregations