[英]Does Spring Security use Basic Auth or Form Based Authentication by default?
[英]How does form based authentication work in spring security?
說post
請求已發送到一些/login
URL,並帶有有效的username
和password
參數。
應該如何應對? 它必須包含jsessionid或/和其他信息嗎?
Spring Security如何識別當前用戶? 它使用jsessionid
過濾還是“查看”其他信息(客戶標頭,Cookie等)? 通過“ jsessionid
過濾”, 我的意思是 (可能是錯誤的),當用戶成功登錄時,彈簧安全性將jsessionid
保存到成功的經過身份驗證的會話列表中,並將其他信息(例如角色)保存到會話對象中。 它是否可以那樣工作?
如果有人逐步提供帶有身份驗證的原始 http請求/響應,例如,應該包含哪些post
請求以及包含哪些對應的響應,那將是很好的。 另外,對受保護資源的請求需要包含什么(某些標頭,cookie,jsession或其他)?
我會盡力幫助您:
首先:響應為該路徑設置一個cookie,在我的情況下,我的應用程序位於localhost:port/CambioClaveDist
,因此,當SpringSecurity驗證我的用戶時,它為該路徑創建一個新的JSESSIONID: Set-Cookie:"JSESSIONID=96ABDF25EE278DD69DD1A0400702E416; Path=/CambioClaveDist"
第二: Spring使用JSESSIONID標識經過身份驗證的用戶,是的。
第三:我有一個http請求/帖子示例:
驗證帖子:
POST http://localhost:8080/CambioClaveDist/j_spring_security_check
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://localhost:8080/CambioClaveDist/index.htm?logout=true
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 92
_csrf=fbd07004-cc30-4ef6-9bfb-a00ae8f8819f&username=user&password=pass&sSubmit=Enviar
要求保護網址:
GET http://localhost:8080/CambioClaveDist/main/index.htm
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://localhost:8080/CambioClaveDist/index.htm?logout=true
Cookie: JSESSIONID=96ABDF25EE278DD69DD1A0400702E416
Connection: keep-alive
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.