Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Feature/encrypt oauth tokens #318

Closed
wants to merge 9 commits into from
Closed

Conversation

baristaGeek
Copy link
Collaborator

Description

We want to improve security and salt access tokens.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Chore: cleanup/renaming, etc
  • RFC

Notes

Acceptance

@watermelon-copilot-for-code-review

WatermelonAI Summary

The two commits in this Pull Request involve adding encryption and decryption utilities for GitHub tokens, with the specific goal of improving security and salting access tokens. This suggests that the business logic is focused on enhancing the protection of sensitive data related to user authentication and authorization. The PR aims to introduce a new feature that adds functionality to the system, in order to ensure the secure handling of OAuth tokens.

GitHub PRs

Click here to login to Jira
Click here to login to Confluence
Click here to login to Slack
Notion Pages deactivated by baristaGeek
Linear Tickets deactivated by baristaGeek
Click here to login to Asana
watermelon is an open repo and Watermelon will serve it for free.
🍉🫶

@vercel
Copy link

vercel bot commented Sep 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
watermelon ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 28, 2023 10:58pm

if(!process.env.ENCRYPTION_KEY) {
throw new Error("Encryption key not found");
}
const key = base64ToUint8Array(process.env.NEXT_PUBLIC_ENCRYPTION_KEY!);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird we have two things in the envelope

@@ -0,0 +1,16 @@
import base64ToUint8Array from "./base64ToUint8Array";

export default function decrypt(ciphertext: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the two processes are so coupled they could go in the same file.

@@ -0,0 +1,8 @@
export default function base64ToUint8Array(base64String: string): Uint8Array {
const binaryString = atob(base64String);
const byteArray = new Uint8Array(binaryString.length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same file is worth it.


export default async function getUser(user): Promise<any> {
try {
let data = await executeRequest(
`EXEC dbo.get_github_token @watermelon_user = '${user}'`
);
return data;
return decrypt(data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all data encrypted?

},
});
let userJson = await user.json();
// save user correctly
await saveUserInfo({
access_token: json.access_token,
access_token: encrypt(json.access_token),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf.

@watermelon-copilot-for-code-review

@baristaGeek
Copy link
Collaborator Author

Not a priority at this time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants