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

Add support to only allow specific origins #104

Closed
laymonage opened this issue Jun 5, 2021 · 9 comments · Fixed by #125
Closed

Add support to only allow specific origins #104

laymonage opened this issue Jun 5, 2021 · 9 comments · Fixed by #125
Labels
enhancement Nice to have

Comments

@laymonage
Copy link
Member

Utterances supports origin allowlisting using utterances.json. This is helpful to prevent unknown sites from using giscus with any user's repository discussions.

@laymonage laymonage added the enhancement Nice to have label Jun 5, 2021
@laymonage
Copy link
Member Author

https://stackoverflow.com/questions/62412608/how-do-i-get-file-contents-from-github-apiv4-on-the-default-branch

{
  repository(owner: $owner, name: $name) {
    object(expression: "HEAD:giscus.json") {
      ... on Blob {
        text
      }
    }
  }
}

This would help us prevent something like utterance/utterances#523.

@laymonage
Copy link
Member Author

Looks like we don't need to use the GraphQL API.

We can just call something like

https://api.github.com/repos/laymonage/giscus/contents/README.md

and get decode the content.

@samarulmeu
Copy link
Contributor

Sorry for the, probably, dumb question, but does it already exists a way to specify that I can allow only my http://example.com site to post and read comments?

@laymonage
Copy link
Member Author

@samarulmeu Hey, no, that's a good question. I'm still working on the feature, it's nearly done. I'm looking to push it this weekend.

@laymonage
Copy link
Member Author

laymonage commented Jul 4, 2021

Sorry for the delay @samarulmeu, I was feeling unwell. It's implemented in #125, you can see the guide here. Please test it when you have the time. Thanks!

@samarulmeu
Copy link
Contributor

@laymonage Thank you so much! This is a great news. I was waiting for this before implementing it on my blog.

I will test it tomorrow.

Take care of your health. It is the most important.

@samarulmeu
Copy link
Contributor

samarulmeu commented Jul 4, 2021

Please tell me if I did something wrong.

You can see the giscus.json file here, but I can still post comments from other domains (https://cttrl-git-fixednav-samarul.vercel.app).

@laymonage
Copy link
Member Author

Hey @samarulmeu, thanks for the report.
I've shipped de316dc which should fix the issue.

image

@samarulmeu
Copy link
Contributor

Thank you! Now it is working. I tested even the regex (the giscus example) and it is working.

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

Successfully merging a pull request may close this issue.

2 participants