Our app is thus:
- Every user must login
- login page posts back to server and if an authorized user a SPA app is returned.
- SPA app is totally AJAX
- HTTPS
Normally we would send a sessionid
cookie and a csrftoken
cookie. The token cookie value would get included as an x-header on any AJAX posts and everything verified on the server on each request.
As the SPA page is built before returning it to the browser we can embed whatever we like in it. We'd like the end user to be able to log in on multiple tabs, with one not affecting the others.
What we would rather do:
- send the sessionid as a cookie, like before, but the cookie name would be random.
- no csrftoken, but instead embed the random cookie name in the javascript routine that added the x-header to the AJAX post requests.
- the server would get the sessionid from the x-header.
This gives us the opportunity to allow multiple logons, with each logon having a unique sessionid
cookie name, but every post request having a standardized x-header name.
Would this be as safe as the sessionid cookie, csrftoken cookie/x-header method?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…