Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : Possible and small Security issue #11

Open
shrutsureja opened this issue May 12, 2024 · 6 comments
Open

fix : Possible and small Security issue #11

shrutsureja opened this issue May 12, 2024 · 6 comments

Comments

@shrutsureja
Copy link
Contributor

if the website URL or the deployment URL is exposed to anyone then if that person hits the deployed_url/twitter-setup and authorizes the twitter from his or her twitter all the tweets will from then move on that person's twitter so need to add some way to authenticate that it the owner only for that here are a few options

  1. on the GET deployed_url/ or deployed_url/authenticate page which is simple form with post method which send just the password to the POST deployed_url/twitter-setup and it authenticates that its you and then work we can save the password in the environment variables
  2. pass the password to GET deployed_url/twitter-setup?password= as a parameter and authenticate it with the environment variable.

Originally posted by @shrutsureja in #9 (comment)

@shrutsureja
Copy link
Contributor Author

shrutsureja commented May 12, 2024

@hkirat It would be great if you can give your opinion on this and i will work on it accordingly.

PS : Thanks a lot for the bounty it was my first earning :)

@rajput-hemant
Copy link

Hi @shrutsureja, here's a possible fix for the error:

TypeError: Cannot read properties of undefined (reading 'get')

1715544318

The 'env' property in the context is an object and does not have a 'get' method, as shown below.
1715544380

Additionally, the 'createFactory' function from Hono is generic, so you can provide the 'Env' struct to make it more type-safe, as shown below.
1715544229
1715544280

You can also remove the 'await' prefixes, as 'c.env.*' won't return a promise.

@shrutsureja
Copy link
Contributor Author

Hi @rajput-hemant thanks for pointing out about the type i include them in the next PR and the error you are facing is also because you might have NOT un-commented the [[kv_namespaces]] in the wrangler.toml file.

image

Now if uncomment the [[kv_namespaces]] in wrangler.toml file the issue will get fixed for the undefined get
image


i have also stated about this in the README.md 3rd point in steps to run locally


I will include the types in the next PR.

@shrutsureja
Copy link
Contributor Author

@rajput-hemant @hkirat I have found a better solution for the KV_namespaces i will make the changes and comment the code well and make a PR tomorrow

@rajput-hemant
Copy link

Hi @shrutsureja , sorry about that. I didn't notice the [[kv_namespaces]] in the wrangler.toml file. It makes sense now why you were awaiting the 'get' call.
Also, take a look at the type struct shown below; you can use this type for making 'createFactory' type-safe.

1715614637

I also noticed a potential typo in your code at line 178 in middleware.ts. In the example env var and in the wrangler.toml file, it's TWITTER_CLIENT_API_SECRET, but in the code, you might have mistyped it as TWITTER_CLIENT_SECRET. If that's not the case, then please double-check to ensure consistency.

1715614594

@shrutsureja
Copy link
Contributor Author

shrutsureja commented May 13, 2024

Hi @rajput-hemant Thanks for pointing out about the TWITTER_CLIENT_SECRET and TWITTER_CLIENT_API_SECRET different variable and that has happened because of the types not being defined, I will include this in the next PR.

The TWITTER_CLIENT_SECRET or api_secret is actually not required for the access token in the loginWithOauth2 function i took reference for this function from here twitter-api-v2 package and they used it. sorry for that. I will complete this tomorrow after my exams.
thanks for pointing this out.

In the next PR

  • Add type safety
  • Remove the API SECRET
  • Change the wrangler.toml structure such that i make it easy to use
  • Add more defined instruction to setup the app in readme
  • Add some basic authentication before sending request to twitter-setup

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

No branches or pull requests

2 participants