我正在開發一個在Google App Engine上運行的GWT應用程序,並想知道我是否需要擔心跨網站請求僞造或者是否會自動照顧我?是一個在Google App Engine上運行的GWT應用程序,受CSRF保護
對於需要驗證每一個RPC請求,我有以下代碼:
public class BookServiceImpl extends RemoteServiceServlet implements
BookService {
public void deleteInventory(Key<Inventory> inventoryKey) throws NotLoggedInException, InvalidStateException, NotFoundException {
DAO dao = new DAO();
// This will throw NotLoggedInException if user is not logged in
User user = dao.getCurrentUser();
// Do deletion here
}
}
public final class DAO extends DAOBase {
public User getCurrentUser() throws NotLoggedInException {
currentUser = UserServiceFactory.getUserService().getCurrentUser();
if(currentUser == null) {
throw new NotLoggedInException();
}
return currentUser;
}
我無法找到如何在UserService
檢查認證的任何文件。依靠上面的代碼還是需要更多?我在這個初學者,但是從我的理解,以避免CSRF攻擊的一些策略是:
- 增加一個認證令牌 請求負載,而不是僅僅 檢查一個cookie
- 檢查HTTP Referer標頭
我可以看到,我已經從谷歌設定是什麼樣子的SID值餅乾,但我可以從序列化的Java對象的有效載荷,如果被通過或不令牌不出來。我也不知道Referer頭是否被使用。
那麼,我擔心一個非問題?如果不是,這裏最好的策略是什麼?這是一個常見的問題,必須有標準的解決方案在那裏......