This commit is contained in:
Eduard Tihomirov 2024-09-30 11:21:57 +03:00
parent 2d8ea9dce9
commit 146fe46638
3 changed files with 9 additions and 3 deletions

View file

@ -40,6 +40,7 @@ import ru.micord.ervu.security.esia.model.EsiaAccessToken;
import ru.micord.ervu.security.esia.model.EsiaTokenResponse;
import ru.micord.ervu.security.esia.model.FormUrlencoded;
import ru.micord.ervu.security.esia.model.OrganizationModel;
import ru.micord.ervu.security.webbpm.jwt.JwtAuthentication;
import ru.micord.ervu.security.webbpm.jwt.service.JwtTokenService;
import ru.micord.ervu.security.webbpm.jwt.model.Token;
@ -232,9 +233,11 @@ public class EsiaAuthService {
authToken.setPath(cookiePath);
authToken.setHttpOnly(true);
response.addCookie(authToken);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(token.getUserAccountId(), null);
SecurityContextHolder.getContext()
.setAuthentication(
new UsernamePasswordAuthenticationToken(esiaAccessToken.getSbj_id(), null));
new JwtAuthentication(usernamePasswordAuthenticationToken, esiaAccessToken.getSbj_id(), token.getValue()));
Cookie isAuth = new Cookie("webbpm.ervu-lkrp-ul", "true");
isAuth.setMaxAge(tokenResponse.getExpires_in().intValue());
@ -330,9 +333,11 @@ public class EsiaAuthService {
authToken.setPath(cookiePath);
authToken.setHttpOnly(true);
response.addCookie(authToken);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(token.getUserAccountId(), null);
SecurityContextHolder.getContext()
.setAuthentication(
new UsernamePasswordAuthenticationToken(esiaAccessToken.getSbj_id(), null));
new JwtAuthentication(usernamePasswordAuthenticationToken, esiaAccessToken.getSbj_id(), token.getValue()));
Cookie isAuth = new Cookie("webbpm.ervu-lkrp-ul", "true");
isAuth.setMaxAge(tokenResponse.getExpires_in().intValue());

View file

@ -47,7 +47,7 @@ public class JwtAuthenticationProvider implements AuthenticationProvider {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(token.getUserAccountId(), null);
return new JwtAuthentication(usernamePasswordAuthenticationToken, token.getUserAccountId());
return new JwtAuthentication(usernamePasswordAuthenticationToken, token.getUserAccountId(), token.getValue());
}
@Override

View file

@ -76,6 +76,7 @@ public class JwtAuthenticationFilter extends AbstractAuthenticationProcessingFil
for (Cookie cookie : cookies) {
if (cookie.getName().equals("auth_token")) {
token = cookie.getValue();
LOGGER.info("Token extracted from cookie: {}", token);
}
}
}