mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-03 08:03:28 +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"];
|
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.
|
* @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(
|
export async function verifyGithubUser(
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
|
|
@ -22,7 +21,6 @@ export async function verifyGithubUser(
|
||||||
try {
|
try {
|
||||||
const octokit = new Octokit({ auth: accessToken });
|
const octokit = new Octokit({ auth: accessToken });
|
||||||
|
|
||||||
// 1. Fetch user information to validate the token
|
|
||||||
const { data: user } = await octokit.users.getAuthenticated();
|
const { data: user } = await octokit.users.getAuthenticated();
|
||||||
|
|
||||||
if (!user || !user.login) {
|
if (!user || !user.login) {
|
||||||
|
|
@ -32,23 +30,6 @@ export async function verifyGithubUser(
|
||||||
return undefined;
|
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;
|
return user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("An error occurred during GitHub user verification:", error);
|
logger.error("An error occurred during GitHub user verification:", error);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue