Tokenized REST API POST handler
POST requests typically modify server state, and are often vulnerable to XSRF attacks. For example, a site admin could be fooled into clicking a button on a rogue website which causes his browser to run REST commands against the server. To prevent against this, REST POST requests should include a token which is first retrieved by making a GET request to the same URL. This token allows us to verify that the user visited the Gerrit site and helps protect against XSRF. An example use-case of this new API: token = $(curl --anyauth -u [user] http://review/a/rest-api | tail -n 1) curl --anyauth -u [user] -d $token http://review/a/rest-api Signed-off-by: Brad Larson <bklarson@gmail.com> Change-Id: I18f3ad2b6be4df2e5a6fa3262de5a2f4601fccea
This commit is contained in:
		 Brad Larson
					Brad Larson
				
			
				
					committed by
					
						 Shawn O. Pearce
						Shawn O. Pearce
					
				
			
			
				
	
			
			
			 Shawn O. Pearce
						Shawn O. Pearce
					
				
			
						parent
						
							513e86debe
						
					
				
				
					commit
					3a6f077932
				
			| @@ -85,5 +85,9 @@ class InitAuth implements InitStep { | ||||
|     if (auth.getSecure("registerEmailPrivateKey") == null) { | ||||
|       auth.setSecure("registerEmailPrivateKey", SignedToken.generateRandomKey()); | ||||
|     } | ||||
|  | ||||
|     if (auth.getSecure("restTokenPrivateKey") == null) { | ||||
|       auth.setSecure("restTokenPrivateKey", SignedToken.generateRandomKey()); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user