Чтобы отобразить блок только для анонимных пользователей:
<div th:if="!${#request.userPrincipal}"> <!-- content for anonymous --> </div>