From 0cdc3fa521a6c7183b8771440d3d9defd2ace101 Mon Sep 17 00:00:00 2001 From: Petr Czepiec Date: Wed, 8 Jan 2025 06:43:10 +0100 Subject: [PATCH 1/2] fix: remove scope user --- src/route/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/route/auth.ts b/src/route/auth.ts index 4d5c06f..ad0e14e 100644 --- a/src/route/auth.ts +++ b/src/route/auth.ts @@ -26,7 +26,7 @@ nanoServer.route('GET', '/auth', (connection) => { const authorizationUri = client.authorizeURL({ redirect_uri: `https://${host}/callback?provider=${provider}`, - scope: 'repo,user', + scope: 'repo', state: randomString(), }); From 2ae80e3ee4e56963f6a3af5871bc6b8c0840ffac Mon Sep 17 00:00:00 2001 From: Petr Czepiec Date: Thu, 9 Jan 2025 21:25:42 +0100 Subject: [PATCH 2/2] feat: set scope with env --- package.json | 2 +- src/config.ts | 2 ++ src/route/auth.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5449057..24d8372 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "contributors": [ "S. Amir Mohammad Najafi (njfamirm.ir" ], - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", "private": true, "type": "module", diff --git a/src/config.ts b/src/config.ts index 0a7389a..1f19739 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,6 +2,7 @@ import { createLogger } from "@alwatr/logger"; const clientId = process.env.OAUTH_GITHUB_CLIENT_ID const clientSecret = process.env.OAUTH_GITHUB_CLIENT_SECRET +const scope = process.env.OAUTH_GITHUB_SCOPE if (clientId == undefined) { throw new Error('github client id required, OAUTH_GITHUB_CLIENT_ID="123_123_123" yarn start'); @@ -15,6 +16,7 @@ export const config = { id: clientId as string, secret: clientSecret as string, }, + scope: scope || 'repo', auth: { tokenHost: 'https://github.com', tokenPath: '/login/oauth/access_token', diff --git a/src/route/auth.ts b/src/route/auth.ts index ad0e14e..44c923a 100644 --- a/src/route/auth.ts +++ b/src/route/auth.ts @@ -26,7 +26,7 @@ nanoServer.route('GET', '/auth', (connection) => { const authorizationUri = client.authorizeURL({ redirect_uri: `https://${host}/callback?provider=${provider}`, - scope: 'repo', + scope: config.scope, state: randomString(), });