Runnable companion for https://ankurm.com/spring-security-7-1-jwt-authentication-guide/ - login -> token issue -> OncePerRequestFilter -> SecurityContext, end to end - HS256 and RS256 variants (RS256 publishes a real JWKS endpoint) - the same API secured by the built-in oauth2ResourceServer().jwt(), for comparison - 11 documentation chapters under docs/, interlinked with the code - docs/output/ is real captured output, regenerated by scripts/run-all.sh - 13 passing tests pinning the 401-vs-403 contract and the CSRF failure Verified against Spring Boot 4.1.1, Spring Security 7.1.1, JDK 25.0.4.1.
32 lines
1.0 KiB
Java
32 lines
1.0 KiB
Java
package com.ankurm.jwtauth;
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
/**
|
|
* Runnable companion for the ankurm.com article
|
|
* "Spring Security 7.1 JWT Authentication: The Complete Guide (Spring Boot 4.1)".
|
|
*
|
|
* <p>Two signing variants are wired as Spring profiles:
|
|
* <ul>
|
|
* <li>{@code hs256} (default) - symmetric HMAC, one shared secret.</li>
|
|
* <li>{@code rs256} - asymmetric RSA, private key signs, public key (JWKS) verifies.</li>
|
|
* </ul>
|
|
*
|
|
* <p>Two validation styles are wired as Spring profiles too:
|
|
* <ul>
|
|
* <li>{@code manual} (default) - a hand-written {@code OncePerRequestFilter}.</li>
|
|
* <li>{@code resourceserver} - Spring Security's built-in
|
|
* {@code oauth2ResourceServer().jwt()} support.</li>
|
|
* </ul>
|
|
*
|
|
* @see docs/01-architecture.md
|
|
*/
|
|
@SpringBootApplication
|
|
public class JwtAuthDemoApplication {
|
|
|
|
public static void main(String[] args) {
|
|
SpringApplication.run(JwtAuthDemoApplication.class, args);
|
|
}
|
|
}
|