java - How to avoid abusive use of REST endpoint -
how can avoid abusive use of rest api? example, have website actions earn bunch of points stored within user account. technically, when ever action performed, call rest endpoint add points user account. action happens within website, therefore there no way check if action has happend within backend.
how can avoid uses javascript debugger find call , triggers directly in order cheat... there principle avoid such kind of abusive use?
edit: here example narrow down question: e.g. have waiting queue can decrease waiting period tweeting page. twitter sdk has callback method fires when user send tweet. when happens, backend called, e.g. api.somedomain.net/user/xyz123?hastweeted=1 or similar.
so question is, how protect last step (call api.somedomain.net), lookup rest url , trigger call manually, without creating tweet.
the answer simple: don't use ui definitive state users. stack overflow great example of this. when voted question, ui updated after rest call backend completed no errors. should waiting each rest call finish before updating state.
in event tries "hack" web page using javascript console, same logic should apply. rest service won't know whence request coming, logic should prevent malicious use, either intentional or unintentional.
edit:
the solution example problem have single rest call tweeting page makes actual rest call twitter from server side code. hastweeted
count incremented when complete , successful call twitter api has finished. still leaves door open malicious users blast out tweets, twitter has in place prevent that.
Comments
Post a Comment