Hi Caleb,
Caleb James DeLisle wrote:
I don't want this proposal to die because of
unnecessary noise which I introduced,
I have thought about it and I am in agreement with the general idea of sending the user a
hash which
must be returned with the post in order for the data to be saved.
I don't like adding code to xwiki-core so I suggest this be made into a component.
We would need 2 functions:
String getToken()
boolean isTokenValid(String token)
getToken uses
org.xwiki.bridge.DocumentAccessBridge.getCurrentUser() to get the user who called it
and the user name is stored in a HashMap of <String, String> with a random string
of text.
If getToken finds a token already in the map, it returns that token (so it may be called
multiple times
in the generation of a page)
So the token is the same for consecutive (GET) requests coming from the
same user?
isTokenValid checks the current user against the
token then removes the entry from the HashMap so the token
may not be reused.
What happens if the user opens in edit mode two different pages? Isn't
the second save invalidated by the first save?
Good point I missed. I would have to have a script to disable such an onerous
'feature' :)
I guess it will only work if a single number is valid basically forever. I wish
components had access to the
Request, Response and Session so it could expire on logout.