简体   繁体   English

如何使用spring-boot验证服务器上两个不同的浏览器?

[英]How to verify two different browsers on the server using spring-boot?

I am using react js for front end and spring boot for backend.我在前端使用 react js,后端使用 spring boot。 Now, I have a situation where I need to get some kind of browser signature or browser specific information to store on the server so that from every new request, I can verify if user is hitting URL from the same browser or from some other browser.现在,我有一种情况,我需要获取某种浏览器签名或浏览器特定信息以存储在服务器上,以便从每个新请求中,我可以验证用户是从同一浏览器还是从其他浏览器点击 URL。

I have tried serveral ways to get browser specific information at backend but not succeed.我尝试了多种方法来在后端获取浏览器特定信息,但没有成功。 Please guide me which browser specific information, I can send get in my spring-boot URL and then store that for further verification process.请指导我使用哪个浏览器特定信息,我可以将 get 发送到我的 spring-boot URL 中,然后将其存储以供进一步验证过程。

Thanks in advance!提前致谢!

I would try to set cookies on the client browser and track the cookie/session value on the server side.我会尝试在客户端浏览器上设置 cookie 并在服务器端跟踪 cookie/会话值。

For example you can set the cookie-例如,您可以设置 cookie-

// create a cookie
Cookie cookie = new Cookie("someUniqueValueLike", uuid);
//add cookie to response
response.addCookie(cookie);

Read cookie读取cookie

public String readCookie(@CookieValue(value = "someUniqueValueLike") String uuidString) {
    //verify the cookie value here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM