I'm building an app that has a separated front-end (Angular or some other JS library) and backend (Django). To ensure some security of requests being sent to the server, I want to append a url parameter say server/someurl?unique_id=Something-unique
.
I am storing this unique code on the machine's localStorage
for a specific time. However, I want to set this code using some sort of function on the server end which will not only generate this random alphanumeric text but also validate it based on incoming requests.
For example:
When a user opens the app, it'll send a server/setCode
which will respond with this randomly generated string which I will store to Local Storage
using JS.
On an outgoing request, say server/getdata?someparameter=some_data&unique_id=string_from_local_storage
which the server can validate against the generating function and only then process the rest of the url.
Is there a package or a module that could help me achieve the generation and validation?
I hope I could convey what I want as I'm not able to find any solution for this short of writing the function to generate and test myself.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…