Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Reviews Spring Boot code for authentication, authorization, input validation, CSRF, secrets, headers, rate limiting and dependencies.
Use this skill ↓78% 87%+9 ptsof test cases passed
Passed 20 of 23 test cases with the skill, and 18 of 23 without it.
3 of 3 safety checks passed
Not used yet
在添加身份验证、处理输入、创建端点或处理敏感密钥时使用。
httpOnly、Secure、SameSite=Strict 的 CookieOncePerRequestFilter 或资源服务器中验证令牌@Component
public class JwtAuthFilter extends OncePerRequestFilter {
private final JwtService jwtService;
public JwtAuthFilter(JwtService jwtService) {
this.jwtService = jwtService;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain chain) throws ServletException, IOException {
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
if (header != null && header.startsWith("Bearer ")) {
String token = header.substring(7);
Authentication auth = jwtService.authenticate(token);
SecurityContextHolder.getContext().setAuthentication(auth);
}
chain.doFilter(request, response);
}
}
@EnableMethodSecurity@PreAuthorize("hasRole('ADMIN')") 或 @PreAuthorize("@authz.canEdit(#id)")Published skills whose descriptions closely match this one, with their benchmark result.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.