mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 13:53:15 +00:00
fix: Drop org membership constraint (#118)
This commit is contained in:
parent
8652faacf4
commit
bbe5502b52
1 changed files with 2 additions and 21 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue