- Spring_Study
- 스프링부트 시큐리티(oauth 2.0) & JWT(stateless token) 강의
- 31 Lectures, 8 Hours 28 Minutes
- 강의 바로가기
- JWT-23부터 중단
// before
public class SecurityConfig extends WebSecurityConfigurerAdapter{
...
@Override
protected void configure(HttpSecurity http) throws Exception {
...
.addFilter(new JwtAuthenticationFilter(authenticationManager()))
...
}
}
// after
public class SecurityConfig {
...
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
...
.apply(new MyCustomDsl()) // 커스텀 필터 등록
...
}
public class MyCustomDsl extends AbstractHttpConfigurer<MyCustomDsl, HttpSecurity> {
@Override
public void configure(HttpSecurity http) throws Exception {
AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class);
http
.addFilter(corsConfig.corsFilter())
.addFilter(new JwtAuthenticationFilter(authenticationManager))
.addFilter(new JwtAuthorizationFilter(authenticationManager, userRepository));
}
}
}
Must clear the cache for gitignore to work properly.
git rm -r --cached .
git add .gitignore
git commit -m "fixed untracked files"
// Object 를 String 으로 변환하여 반환
Object obj = session.getAttribute("user_name");
String user_name = obj.toString();
// String 자료형임을 명시
Object obj = session.getAttribute("user_name");
String user_name = (String)obj;
// UserEntity.java
@Entity
@Data
public class User {
@Id // primary Key
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String username;
private String password;
private String email;
private String role; // ROLE_USER, ROLE_ADMIN
@CreationTimestamp
private Timestamp crateDate;
}
// UserRepository.interface
public interface UserRepository extends JpaRepository<User, Integer> { // User 의 primaryKey 는 Integer
// findBy 규칙, Username 문법
// select * from user where username = ?
public User findByUsername(String username);
// findBy 규칙, Email 문법
// select * from user where email = ?
public User findByEmail(String email);
}
// Before
@Override
public void configure(WebSecurity web){
web.ignore().antMatchers("/assets/**", "/h2-console/**", "/api/hello2");
}
// After
@Bean
public WebSecurityCustomizer webSecurityCustomizer(){
return (web) -> web.ignoring().antMatchers("/assets/**", "/h2-console/**", "/api/hello2");
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.