Fix GitHub grant checker not checking the correct ID (#665)

* Remove the need for a grant key

* changelog
This commit is contained in:
Will Hunt 2023-03-20 22:38:44 +00:00 committed by GitHub
parent 8071243696
commit 61ede0b97a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

1
changelog.d/665.bugfix Normal file
View File

@ -0,0 +1 @@
Fix GitHub grant checker applying a different grant ID than the one it checks for.

View File

@ -28,7 +28,6 @@ import { PermissionCheckFn } from ".";
import { MinimalGitHubIssue, MinimalGitHubRepo } from "../libRs";
import Ajv, { JSONSchemaType } from "ajv";
import { HookFilter } from "../HookFilter";
import { GrantChecker } from "../grants/GrantCheck";
import { GitHubGrantChecker } from "../Github/GrantChecker";
const log = new Logger("GitHubRepoConnection");
@ -399,7 +398,7 @@ export class GitHubRepoConnection extends CommandConnection<GitHubRepoConnection
);
}
const stateEventKey = `${validData.org}/${validData.repo}`;
await new GrantChecker(as.botIntent, 'github').grantConnection(roomId, this.getGrantKey(validData.org, validData.repo));
await new GitHubGrantChecker(as, github, tokenStore).grantConnection(roomId, { org: validData.org, repo: validData.repo });
await intent.underlyingClient.sendStateEvent(roomId, this.CanonicalEventType, stateEventKey, validData);
return {
stateEventContent: validData,
@ -1415,10 +1414,6 @@ export class GitHubRepoConnection extends CommandConnection<GitHubRepoConnection
}
return true;
}
public static getGrantKey(org: string, repo: string) {
return `${this.CanonicalEventType}/${org}/${repo}`;
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any