[Notes] GraphQL vs. REST: What you didn’t know

The focus with GraphQL is more on how data is queried and less on how resources are modeled.

To start with, a GraphQL query could map to many different resolving functions, any of which could fail. As a result, a response could be partially successful and partially failed at the same time.

This vulnerability exists with other servers as well, but in the case of a GraphQL server, your API schema may expose potentially complex and expensive query patterns that could bring down your system easily.

[Notes] The Ultimate Guide to handling JWTs on frontend clients (GraphQL)

The Ultimate Guide to handling JWTs on frontend clients (GraphQL)
— Read on blog.hasura.io/best-practices-of-using-jwt-with-graphql/

So far, this is the best article I have read that explains and answers questions on JWT (both server and client.)

That’s why it’s also really important not to store JWT on the client, say via cookies or localstorage. Doing so you make your app vulnerable to CSRF & XSS attacks, by malicious forms or scripts to use or steal your token lying around in cookies or localstorage.

So memory only? For cookies, with HttpOnly and Secure, there should be no concern about XSS or man-in-the-middle. Yes, chance of CSRF is still there. So you need anti-forgery. For example, keeping an anti-forgery token in localstorage (since value in localstorage won’t be sent automatically with each request.)

So it really depends on the balance of security vs. cost to keep it absolutely secure.

A very good point has been made in this SO thread.

This is a painful discussion on the Internet. Our short (and opinionated answer) is that backend developers like using JWTs because a) microservices b) not needing a centralized token database.

Indeed yes, the two most important benefits.

This token is issued as part of authentication process along with the JWT. The auth server should saves this refresh token and associates it to a particular user in its own database, so that it can handle the renewing JWT logic.

The refresh token is sent by the auth server to the client as an HttpOnly cookie and is automatically sent by the browser in a /refresh_token API call.

Persisting JWT token in localstorage (prone to XSS) < Persisting JWT token in an HttpOnly cookie (prone to CSRF, a little bit better for XSS) < Persisting refresh token in an HttpOnly cookie (safe from CSRF, a little bit better for XSS).

[Notes] 6 Lessons we learned when debugging a scaling problem on GitLab.com

https://about.gitlab.com/2019/08/27/tyranny-of-the-clock/

The first step is to look for critical filters to dramatically reduce the area to troubleshoot. Such as type of logs, which server, etc.

Wireshark statistics tools could be super helpful.

If usage pattern aligns with some timing cadence, think scheduled jobs.

If the incoming rate exceeds the limit (measured every millisecond) the new connections are simply delayed. The TCP client (SSH in this case) simply sees a delay before the TCP connection is established, which is delightfully graceful, in my opinion. 

Why? Rate limiting should be used for defensive needs, where it prevents from handling the unexpected requests. But in this case, those requests are expected and expect to be processed.

When you choose specific non-default settings, leave a comment or link to documentation/issues as to why, future people will thank you.

That applies to all things non-default, such as “magic numbers,” workarounds, tricks, possible valid values, etc.

Moving a placeholder site from Squarespace to Github Page

I have been owning a domain and an LLC with the same name.

Squarespace was my choice since I was about put in more than just a placeholder. $144/year was not bad considering the time it saves me given the features, designs, and flexibility it provides.

However, it ends up a nice looking one-pager is all I need for now. The yearly renewal is around the corner. I decided to move it to Github Page, which is totally free.

Here are the steps:

  1. Create a Github Page.
    1. Login to Github with your username (e.g., examplegithublogin)
    2. Create a new empty repo, examplegithublogin.github.io
    3. Use SourceTree to check it out to a folder locally
    4. Find a free template (on https://www.free-css.com/ etc.), put in the folder, commit and push.
    5. Go to the site (examplegithublogin.github.io) directly. Double check everything works fine.
  2. Unlink from Squarespace
    1. log in to Squarespace -> settings -> domains, then Unlink
    2. If needed, stop auto-renew on Squarespace.
  3. Setup A record
    1. For example, if your domain is registered with Google domains, log in to Google Domains
    2. Remove the Squarespace “Synthetic records”
    3. Add a “@” record, points to the following 4 IP’s (185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153).
  4. Add the custom domain to Github Page settings
    1. Go back to the examplegithublogin.github.io repo -> settings -> GitHub Pages -> Custom domain -> put yourcustomdomain.com in -> save
  5. Check yourcustomdomain.com and http://www.yourcustomdomain.com (with and without https://)
    1. It works for me immediately, but it could take you more time depends on your DNS propagation.
    2. For me, SSL took about 3 mins to start working. (Github needs to issue a certificate behind the scene.)
  6. Done.