본문 바로가기

스프링부트

(4)
데이터 바인딩 양방향 단방향 바인딩 설명 단방향 바인딩은 한 엔티티가 다른 엔티티를 참조하는 것으로, 다른 엔티티는 참조되는 엔티티를 알지 못한다 예를 들어, Author 엔티티가 Book 엔티티를 참조할 때 Author.java @Entity public class Author { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; // 단방향 바인딩 @ManyToOne private Book book; } Book.java @Entity public class Book { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String..
OAuth2 - authorization code grant type 설명 bearer token - 토큰을 소유한 사람에게 액세스 권한을 부여하는 일반적인 토큰 클래스 점선화살표는 redirection을 의미(요청 또는 응답 x) authorization code ≠ access token :access token은 클라이언트가 마지막에 백엔드에서 승인을 받기 위해 필요한 것(단계7) 단계4에서 authorization code 대신에 직접 access token을 주면 단계가 줄어 들 것이라고 생각할 수 있다. OAuth1에서는 단계4에서 access token을 바로 주었다 그것이 " implicit grant type"이다. 하지만 이렇게 해버리면 redirect가 쉽게 intercept될 수 있고 개인이 access token을 쉽게 얻을 수 있기 때문에 authori..
Oauth2 사용자 - Use case를 실행하려는 사람 Client - resource server에게 요청 및 응답 받음 Authorization Server - 사용자와 클라이언트 세부 정보를 관리하고 인증하도록 허용하며 권한 부여 수단으로 사용할 토큰을 제공 Resource Server - Authorization Server에게 Access Token을 부여 받은 Client가 요청을 하여 특정 Use case를 실행하거나 resource에 액세스 권한을 부여 OpenID Connect : OAuth2를 사용 할 때 일부 제약을 적용하여 OAuth2 클라이언트를 구현하는 프로토콜이다. Grant Type : 클라이언트가 토큰을 얻는 과정이다. password grant type과 implicit grant ..
WebSecurityConfigurerAdapter 대체 하기 WebSecurityConfigurerAdapter는 스프링 시큐리티를 사용할 때 기본적인 시큐리티 설정을 위해 사용되었다. WebSecurityConfigurerAdapter라는 추상 클래스를 상속하여 configure 메소드를 오버라이드하여 설정했었다. 이제는 bean으로 등록하여 사용한다. @EnableWebSecurity @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Bean public BCryptPasswordEncoder encodePwd() { return new BCryptPasswordEncoder(); } @Override protected void configure(HttpSecur..