fix: Drop org membership constraint (#118)

This commit is contained in:
Brace Sproul 2025-06-11 15:48:12 -07:00 • committed by GitHub
parent 8652faacf4
commit bbe5502b52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,10 +7,9 @@ const logger = createLogger(LogLevel.INFO, "GithubAuth");
export type GithubUser = Endpoints["GET /user"]["response"]["data"];
/**
* Verifies a GitHub user access token and checks for membership in the 'langchain-ai' organization.
*
* Verifies a GitHub user access token.
* @param accessToken The GitHub user access token.
* @returns A promise that resolves with the user object if valid and a member, otherwise undefined.
* @returns A promise that resolves with the user object if valid, otherwise undefined.
*/
export async function verifyGithubUser(
accessToken: string,
@ -22,7 +21,6 @@ export async function verifyGithubUser(
try {
const octokit = new Octokit({ auth: accessToken });
// 1. Fetch user information to validate the token
const { data: user } = await octokit.users.getAuthenticated();
if (!user || !user.login) {
@ -32,23 +30,6 @@ export async function verifyGithubUser(
return undefined;
}
const username = user.login;
// 2. List organizations for the user
const { data: orgs } = await octokit.orgs.listForUser({
username,
});
// 3. Check for 'langchain-ai' organization membership
const isMember = orgs.some((org) => org.login === "langchain-ai");
if (!isMember) {
logger.info(
`User ${username} is not a member of the 'langchain-ai' organization.`,
);
return undefined;
}
return user;
} catch (error) {
logger.error("An error occurred during GitHub user verification:", error);