From d1647b7a056f04ad5828976dd5a7e2e06b431feb Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sun, 26 Jan 2025 23:55:50 +0100 Subject: Stop using current user in git hooks Want to support any authentication for the git server, so use git commiter as username for creating reviews instead of the local user that logged in to git. Also verify that pushed commits has a valid author in pre-receive. This is tricky as pre-receive must do this check in the hook, because pre-receive runs when before the objects are pushed so the server can't read the commits, the hook must do this. --- server/src/git_socket.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'server/src/git_socket.rs') diff --git a/server/src/git_socket.rs b/server/src/git_socket.rs index 90f9dc2..a4805be 100644 --- a/server/src/git_socket.rs +++ b/server/src/git_socket.rs @@ -5,12 +5,15 @@ pub struct GitReceive { pub old_value: String, pub new_value: String, pub reference: String, + // Only set for pre hooks, because server can't read the objects the pre-hook has not yet + // accepted, so to be able to validate the commiter, send them. Also only set if new_value + // is not empty. + pub commiter: Option, } #[derive(Deserialize, Serialize)] pub struct GitHookRequest { pub pre: bool, - pub user: String, pub receive: Vec, } -- cgit v1.2.3-70-g09d2