Skip to content

Commit 2d2a551

Browse files
authored
Merge pull request #227 from vishnoianil/fix-auth
Add environment variable to set the authentication org
2 parents a1394b7 + f71daf0 commit 2d2a551

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

.env.example

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
IL_UI_ADMIN_USERNAME=admin
22
IL_UI_ADMIN_PASSWORD=password
3+
34
OAUTH_GITHUB_ID=<OAUTH_APP_ID>
45
OAUTH_GITHUB_SECRET=<OAUTH_APP_SECRET>
5-
GITHUB_TOKEN=<TOKEN FOR OAUTH INSTRUCTLAB MEMBER LOOKUP>
6+
67
NEXTAUTH_SECRET=your_super_secret_random_string
78
NEXTAUTH_URL=http://localhost:3000
89

9-
TAXONOMY_DOCUMENTS_REPO=github.com/<USER_ID>/<REPO_NAME>
10-
NEXT_PUBLIC_TAXONOMY_REPO_OWNER=<GITHUB_ACCOUNT>
11-
NEXT_PUBLIC_TAXONOMY_REPO=<REPO_NAME>
12-
1310
IL_GRANITE_API=<GRANITE_HOST>
1411
IL_GRANITE_MODEL_NAME=<GRANITE_MODEL_NAME>
1512
IL_MERLINITE_API=<MERLINITE_HOST>
1613
IL_MERLINITE_MODEL_NAME=<MERLINITE_MODEL_NAME>
14+
IL_UI_DEPLOYMENT=dev ## Comment it out if it's not a dev deployment
15+
16+
GITHUB_TOKEN=<TOKEN FOR OAUTH INSTRUCTLAB MEMBER LOOKUP>
17+
TAXONOMY_DOCUMENTS_REPO=github.com/instructlab-public/taxonomy-knowledge-docs
18+
NEXT_PUBLIC_AUTHENTICATION_ORG=<AUTHENTICATION_ORG>
19+
NEXT_PUBLIC_TAXONOMY_REPO_OWNER=<GITHUB_ACCOUNT>
20+
NEXT_PUBLIC_TAXONOMY_REPO=<REPO_NAME>

src/app/api/auth/[...nextauth]/route.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const logger = winston.createLogger({
3737
transports: [new winston.transports.Console(), new winston.transports.File({ filename: path.join(process.cwd(), 'auth.log') })]
3838
});
3939

40-
const ORG = process.env.NEXT_PUBLIC_TAXONOMY_REPO_OWNER!;
40+
const ORG = process.env.NEXT_PUBLIC_AUTHENTICATION_ORG!;
4141

4242
const authOptions: NextAuthOptions = {
4343
providers: [
@@ -107,16 +107,16 @@ const authOptions: NextAuthOptions = {
107107
});
108108

109109
if (response.status === 204) {
110-
console.log(`User ${githubProfile.login} logged in successfully with GitHub`);
111-
logger.info(`User ${githubProfile.login} logged in successfully with GitHub`);
110+
console.log(`User ${githubProfile.login} successfully authenticated with GitHub organization - ${ORG}`);
111+
logger.info(`User ${githubProfile.login} successfully authenticated with GitHub organization - ${ORG}`);
112112
return true;
113113
} else if (response.status === 404) {
114114
console.log(`User ${githubProfile.login} is not a member of the ${ORG} organization`);
115115
logger.warn(`User ${githubProfile.login} is not a member of the ${ORG} organization`);
116116
return `/error?error=AccessDenied`; // Redirect to custom error page
117117
} else {
118-
console.log(`Unexpected error for user ${githubProfile.login} during organization membership verification`);
119-
logger.error(`Unexpected error for user ${githubProfile.login} during organization membership verification`);
118+
console.log(`Unexpected error while authenticating user ${githubProfile.login} with ${ORG} github organization.`);
119+
logger.error(`Unexpected error while authenticating user ${githubProfile.login} with ${ORG} github organization.`);
120120
return false;
121121
}
122122
} catch (error) {

src/app/api/pr/knowledge/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function POST(req: NextRequest) {
3737

3838
// Fetch GitHub username
3939
const githubUsername = await getGitHubUsername(headers);
40-
console.log('GitHub Username:', githubUsername);
40+
console.log('Knowledge contribution from gitHub Username:', githubUsername);
4141

4242
// Check if user's fork exists, if not, create it
4343
const forkExists = await checkUserForkExists(headers, githubUsername, UPSTREAM_REPO_NAME);

src/app/api/pr/skill/route.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const UPSTREAM_REPO_NAME = process.env.NEXT_PUBLIC_TAXONOMY_REPO!;
1414

1515
export async function POST(req: NextRequest) {
1616
const token = await getToken({ req, secret: process.env.NEXTAUTH_SECRET! });
17-
console.log('GitHub Token:', token);
1817

1918
if (!token || !token.accessToken) {
2019
console.error('Unauthorized: Missing or invalid access token');
@@ -34,7 +33,7 @@ export async function POST(req: NextRequest) {
3433
const { content, attribution, name, email, submissionSummary, documentOutline, filePath } = body;
3534

3635
const githubUsername = await getGitHubUsername(headers);
37-
console.log('GitHub Username:', githubUsername);
36+
console.log('Skill contribution from gitHub Username:', githubUsername);
3837

3938
// Check if user's fork exists, if not, create it
4039
const forkExists = await checkUserForkExists(headers, githubUsername, UPSTREAM_REPO_NAME);

0 commit comments

Comments
 (0)