---
title: 'Spring Boot login觀念'
disqus: hackmd
---
###### tags: `SpringBoot`
Spring Boot login
===
[TOC]
## 觀念
如何不使用框架來寫一個登入
You don't need Spring Security, or any framework for that matter - the basic task of Authentication/Authorization can be done in 3 steps:
1. Write a Log In page, with a Form that accepts Username and Password (e.g. in a JSP)
2. Write a Controller method that reads the specified unique User's Password (Hashed!) from the Form and verifies it matches the (Hashed!) Password retrieved from a DB. If they match, store a Token in the Session object.
3. Implement a Filter, that checks whenever the User tries to access a Secured page, that a valid Token object exists in the current Session
WebMvcConfigurer 和 HandlerInterceptor 基本上是綁在一起的
## 參考資料
[必看 Spring Boot Registration Login and Logout Example with Spring Security, Thymeleaf, Spring Data JPA and Hibernate](https://hellokoding.com/spring-security-login-logout-thymeleaf/)
1.[在Spring Controller中将数据缓存到session](https://www.cnblogs.com/ywjy/p/5016034.html)
2.[菜鳥工程師](https://matthung0807.blogspot.com/2019/09/spring-boot-security-form-api-login.html)
3.[Login without spring security](https://stackoverflow.com/questions/61723119/login-without-spring-security)
4.[spring 的攔截器](https://blog.csdn.net/xue_xiaofei/article/details/111312035)
5.[NeverStarve](https://github.com/padaray/NeverStarve/blob/master/src/main/java/com/NeverStarve/member/controller/LoginController.java)
6.[Spring Boot Security Authentication with JPA, Hibernate and MySQL](https://mail.codejava.net/frameworks/spring-boot/spring-boot-security-authentication-with-jpa-hibernate-and-mysql?fbclid=IwAR2F1wA7XOCO-ci-AaAAnSivdtY49A5qGBmGY0wTKQ_i5lRoLIY1xOvEtlM)
7.[Spring MVC 4 - @SessionAttributes or @SessionAttribute example](https://www.boraji.com/spring-mvc-4-sessionattributes-example)
8.[session的三種用法(https://www.itread01.com/content/1547017758.html)
9.[進階web程式設計session 還有購物車](https://sites.google.com/im.fju.edu.tw/web/spring-framework/spring-session)
10.[spring login with httpsession](https://learningprogramming.net/java/spring-mvc/login-form-with-session-in-spring-mvc/)
11.[medium spinrg boot mvc jpa ](https://medium.com/@gustavo.ponce.ch/spring-boot-spring-mvc-spring-security-mysql-a5d8545d837d)
[](https://x8795278.blogspot.com/2019/12/spring-boot-spring-security-loginmenu.html)