Skip to content

Commit

Permalink
Security configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioT90 committed Jan 5, 2025
1 parent cc3e777 commit 2fcae63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected void doFilterInternal(@Nonnull HttpServletRequest request, @Nonnull Ht
if (StringUtils.hasText(authorization)) {
String token = authorization.replace("Bearer ", "");
DecodedJWT decodedJWT = jwtVerifier.verify(token);
String externalUserId = decodedJWT.getIssuer();
String externalUserId = decodedJWT.getSubject();
MDC.put("externalUserId", externalUserId);
UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(externalUserId, token, null);
SecurityContextHolder.getContext().setAuthentication(authToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@ExtendWith(MockitoExtension.class)
class JwtAuthenticationFilterTest {

// public key and JWT token sample obtained through p4pa-auth test it.gov.pagopa.payhub.auth.service.AccessTokenBuilderServiceTest
private static final String PUBLIC_KEY = """
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2ovm/rd3g69dq9PisinQ
Expand All @@ -33,9 +34,8 @@ class JwtAuthenticationFilterTest {
IwIDAQAB
-----END PUBLIC KEY-----
""";

private static final String JWT_TOKEN_USERID = "MAPPEDEXTERNALUSERID";
private static final String JWT_TOKEN = "eyJraWQiOiIyNWNhZDlkYi0wMDIyLTNiODctYTcwYS1mMmRhMjcyMTdjODgiLCJ0eXAiOiJhdCtKV1QiLCJhbGciOiJSUzUxMiJ9.eyJ0eXAiOiJiZWFyZXIiLCJpc3MiOiJNQVBQRURFWFRFUk5BTFVTRVJJRCIsImp0aSI6IjBlNTM5NzRlLTczMTktNGU4Yi04OTNhLTEzYWY0ZGY2MjA2ZCIsImlhdCI6MTczNjAwODAwMCwiZXhwIjoyNzM2MDA3OTk5fQ.e1eO-qN2wxgxuA90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kXU_2w3pj4u6sIZsWuTNGT4d8zBye8JA";

@Mock
private HttpServletRequest httpServletRequestMock;
Expand Down

0 comments on commit 2fcae63

Please sign in to comment.