Skip to content

Commit

Permalink
Idporten userinfo request mer logging
Browse files Browse the repository at this point in the history
#deploy-dolly-backend
  • Loading branch information
stigus committed Aug 23, 2024
1 parent a6a8967 commit 4e6376c
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
import no.nav.testnav.libs.securitycore.domain.UserInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.Callable;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

@Slf4j
@Component
Expand All @@ -27,6 +30,16 @@ public GetUserInfo(@Value("${JWT_SECRET:#{null}}") String secret) {

@Override
public Optional<UserInfo> call() {
var req = RequestContextHolder.getRequestAttributes();

if (nonNull(req)) {
log.info(Arrays.stream(req.getAttributeNames(RequestAttributes.SCOPE_REQUEST)).reduce("Request attributes: ", (acc, name) -> {
if (acc.length() != 11 && name.length() != 11) {
return acc + name + ", ";
}
return "";
}));
}
var requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (isNull(requestAttributes)) {
log.warn("Fant ikke request attributes i context.");
Expand Down

0 comments on commit 4e6376c

Please sign in to comment.