minor fixes and bring back schema verification on /_ssh/auth
+ 9
- 2
app/controllers/ssh-auth.ts
@@ -35,6 +35,9 @@ const onSSHAuth: ReqHandler<AppRouteParams, AppRoute.SSH_AUTH> = async (
     ? gitRepositoryDir
     : `${gitRepositoryDir}.git`;
 
+  console.log("authMode:", authMode);
+  console.log("gitRepositoryDir:", gitRepositoryDir);
+
   if (
     authMode === GitServer.AuthMode.NEVER ||
     (authMode === GitServer.AuthMode.PUSH_ONLY &&

@@ -348,7 +348,6 @@ export const AppRouteSchemas: Record<AppRoute, undefined | FastifySchema> = {
       required: ["command", "repoSlug", "username", "publicKey"],
       additionalProperties: false,
       properties: {
-        // git-receive-pack: push, git-upload-pack: clone, pull, fetch
         command: {
           type: "string",
           enum: ["git-receive-pack", "git-upload-pack"],

@@ -70,6 +70,7 @@ const RootAppRouter: AppRouter<AppRouteParams> = () => {
           name={AppRoute.SSH_AUTH}
           method={"POST"}
           path={AppRoutePaths[AppRoute.SSH_AUTH]}
+          schema={AppRouteSchemas[AppRoute.SSH_AUTH]}
           handler={SSHAuthController.onSSHAuth}
         />
         {/* --- */}

app/services/gitServer/authorizationResolver.ts
@@ -81,7 +81,11 @@ const makeAuthorizationResolver: ServiceMethodFactory<
           },
         });
 
-        return matchingPk != null && matchingPk.user.id === user.id;
+        return (
+          matchingPk != null &&
+          matchingPk.user.id === user.id &&
+          matchingPk.user.username === username
+        );
       } else {
         const hashedPassword = cryptoService.computeHash(password);
         return hashedPassword === user.hashedPassword;