스프링/스프링 시큐리티

csrf 적용

까마귀! 2024. 3. 23. 22:47

 

csrf: 사용자도 모르게 서버에 강제로 요청을 보내는 해킹 방식

 

 

application.properties

 

# mustache csrf token 받을 수 있게 함
spring.mustache.servlet.expose-request-attributes=true

 

 

login.mustache
<body>
login page
<hr>
<form action="/loginProc" method="post" name="loginForm">
    <input id="username" type="text" name="username" placeholder="id" />
    <input id="password" type="password" name="password" placeholder="password" />
    <input type="hidden" name="_csrf" value="{{_csrf.token}}" />  -> csrf 토큰 생성
    <input type="submit" value="login"/>
</form>
</body>

 

'스프링 > 스프링 시큐리티' 카테고리의 다른 글

Http Basic  (0) 2024.03.23
InMemory  (0) 2024.03.23
세션 설정  (0) 2024.03.23
로그인 검증 로직  (0) 2024.03.23
회원가입 로직  (0) 2024.03.23