Better HN
topnewbestaskshowjobs
Log inSign up

rmedaer

110 karma · joined Oct 10, 2017 (9y ago) · 68 submissions

Submissions

comment 3y ago · link · parent

TLDR: You can split the JWT into 3 parts and store them differently in cookies to keep the _payload_ accessible in JavaScript and make the _signature_ inaccessible from the web app.

In the following Stackoverflow thread (https://stackoverflow.com/a/60941643) I described a way to store a JWT in Cookies while keeping convenient to use payload from the Javascript stack (for instance to display the user name).

This is achieved by splitting the JWT in 3 parts (header, payload and signature) and storing it into 3 different Cookies which have different properties. The _header_ and _payload_ would be accessible from the web application while the _signature_ is configured with HttpOnly and therefore unaccessible from the web app. The inconvenient of this method is that you have to reconstruct/concat the 3 parts server side.

Disclaimer: it's actually an experiment which has for purpose to get the better of both world and it has not been tested from security standpoint.

comment 4y ago · link · parent

IMO Stripe API[^1] is following well the REST principles and constraints. Btw, if I well remember, they are not using PUT at all while they obviously allow users to update some resources.

They implemented an "Idempotency-Key" header that you could maybe call a "shortcut". Although it's not really deviating from HTTP standards. I guess it was easier and more pragmatic for Stripe and users to implement an "Idempotency-Key" header instead of duplicating each POST endpoint with PUT and PATCH methods since they also allow partial updates. I guess (again) that they would also have to use/implement additional header (such as ETag or If-Match) to replicate current "Idempotency-Key" header behavior.

Disclaimer: This last paragraph is full of assumptions and I most probably miss a lot of internal details from Stripe API.

[^1] https://stripe.com/docs/api

comment 4y ago · link · parent

I promised myself to never-ever answer the "CRUD vs HTTP verbs" topic. I could not resist.

It is a huge shortcut to map CRUD operations to HTTP verbs POST, GET, PUT, DELETE. By the way, the definition of HTTP verbs defined in the HTTP RFCs (from RFC 1945 to RFC 7231) and the original thesis from Roy Fielding about REST (which is defining REST principles as an architectural style) never talk about one-to-one relationship between CRUD and PUT-GET-POST-DELETE.

While I understand that it might be confusing without deep-diving in long-long-lectures, the last RFC explains clearly what is the purpose of each HTTP verb including the difference between PUT and POST:

   The fundamental difference between the POST and PUT methods is
   highlighted by the different intent for the enclosed representation.
   The target resource in a POST request is intended to handle the
   enclosed representation according to the resource's own semantics,
   whereas the enclosed representation in a PUT request is defined as
   replacing the state of the target resource.  Hence, the intent of PUT
   is idempotent and visible to intermediaries, even though the exact
   effect is only known by the origin server.
Therefore it would be perfectly valid to "create" a resource with both PUT and POST methods as well as "update" another one with, also, PUT and POST. It is actually even clearly stated with a few examples in the RFC. For instance in POST definition:

   Appending data to a resource's existing representation(s).
I used to defined PUT and POST requests according their characteristics: the first one is idempotent, the second is not ... but could be. Therefore, in my understanding, it is perfectly valid to perform an "upsert" (insert or update) to a resource which doesn't exist yet but for which you already know the URL, it is indeed idempotent. For instance:

   PUT /resources/xyz
A last piece of evidence is the first line of PUT section in RFC 7231:

   The PUT method requests that the state of the target resource be
   created or replaced with the state defined by the representation
   enclosed in the request message payload.
I hope it helps to clarify a little bit the topic.

4.

Prevent Forwarded header spoofing with HTTP message signature(raphael.medaer.me ↗)

1 points · by rmedaer · 4y ago · discuss

5.

Ask HN: PCI-DSS (level 3/4) for a one-man business?

1 points · by rmedaer · 4y ago · discuss

6.

Ask HN: Is Progressive Enhancement still relevant in 2022?

6 points · by rmedaer · 4y ago · 7 comments

comment 4y ago · link · parent

No lag at all on Firefox. Still have some unsupported GPU related features on Chrome.

comment 4y ago · link · parent

I own a ThinkPad X1 Yoga Gen 6 with a 11th Generation Intel® Core™ i7 and an integrated Intel® Iris® Xe Graphics. I'm not playing games. I use an external "5K2K" LG monitor (basically 2x 4K monitor) through Thunderbolt 4 port.

Really happy with this setup.

comment 4y ago · link · parent

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status ?

10.

Writing a Node.js loader for native CSS modules(raphael.medaer.me ↗)

1 points · by rmedaer · 4y ago · discuss

11.

Another Better Git Flow(raphael.medaer.me ↗)

2 points · by rmedaer · 4y ago · discuss

12.

Attempt to standardize the JavaScript API to encode/decode CBOR(github.com ↗)

1 points · by rmedaer · 4y ago · discuss

comment 4y ago · link · parent

Really? Reading blogs, articles, etc. 99% of them say "POST is idempotent". They never say "but it could be".

14.

Yes, a POST can be idempotent, said HTTP RFC editor(twitter.com ↗)

1 points · by rmedaer · 4y ago · 4 comments

15.

OAuth flow to obtain JWT without user consent(stackoverflow.com ↗)

1 points · by rmedaer · 4y ago · discuss

16.

How to get OAuth access token without resource owner consent?(stackoverflow.com ↗)

1 points · by rmedaer · 5y ago · discuss

17.

BlimpDrive: Stupid-Simple Electric Paramotor(youtube.com ↗)

2 points · by rmedaer · 5y ago · discuss

18.

How to Write an RFC – A Tutorial (2005) [pdf](ietf.org ↗)

1 points · by rmedaer · 5y ago · discuss

19.

T-Shirt Size Estimation (Agile)(explainagile.com ↗)

1 points · by rmedaer · 5y ago · discuss

20.

Another Successful Git Flow(raphael.medaer.me ↗)

2 points · by rmedaer · 5y ago · discuss

21.

Yet another successful Git branching model(raphael.medaer.me ↗)

2 points · by rmedaer · 5y ago · discuss

comment 5y ago · link · parent

Actually there is a missing alternative to Mapbox, Google Places and Geocode Earth. As they explain it this blog post, Algolia Places relies on OSM Open Source community to maintain accurate data. Since it's not anymore a business for Algolia, they could Open Source their software (API, user-agents and tooling) and let an Open Source community maintain the software. Not only the data from OSM.

It would be a nice sign from Algolia towards their customers.

23.

Sunset of Algolia Places Feature(algolia.com ↗)

5 points · by rmedaer · 5y ago · 1 comment

24.

Server Side Includes (SSI)(en.wikipedia.org ↗)

1 points · by rmedaer · 5y ago · discuss

comment 6y ago · link · parent

IMO it might be a good idea to store binary assets in Git from a "history management" point of view.

However it's a mess when you have to deal with a lot of huge files. Not especially because of bad-habit but because it's hard to manage on day-to-day and you will face a lot of issues.

One of the issues I got recently is the time required to switch between branches (if LFS-tracked files are changing). It is due to the "checkout" and how git-lfs works (see the Github issue). Actually it copies the file... This operation takes time... Instead it could use hard-link or symbolic-link.

26.

Git filtering mechanism isn't intended to be used the way Git LFS has used it(github.com ↗)

9 points · by rmedaer · 6y ago · 14 comments

comment 6y ago · link · parent

I would like to thank you for your feedback. If you still have a little bit of time, here is a quick survey to get more feedback about your needs! https://ku.ag/6dmohc20fvnd

Kind regards,

123