Commit Graph

6 Commits

Author SHA1 Message Date
Lorenzo Blasa
c6d5eb3334 Flipper as PWA
Summary:
^

Reference: https://docs.google.com/document/d/1flQJUzTe4AuQz3QCpvbloQycenHsu7ZxbKScov7K7ao

Reviewed By: passy

Differential Revision: D45693382

fbshipit-source-id: 5a2e6c213a7e7e2cf9cd5f3033cff3e5291a2a92
2023-05-16 04:32:47 -07:00
Lorenzo Blasa
fdd1a9e887 Use different location for token depending on build type
Summary:
For Electron builds, use the same directory as certificates and keys.

For headless builds, then use the static directory.

Reviewed By: antonk52

Differential Revision: D45728515

fbshipit-source-id: 55a3b143a9289fed23e57cbf6b701a5e48d27332
2023-05-10 04:35:17 -07:00
Lorenzo Blasa
238f40f55d Mandate auth token to connect over TCP
Summary:
Until now, launching flipper-server with TCP would accept any incoming connection as long as it comes from the same origin (localhost) using web socket host origin verification.

This is not entirely secure as origin can be spoofed with tools like curl.

Our team created a security review and a proposal was written:
https://docs.google.com/document/d/16iXypCQibPiner061SoaQUFUY9tLVAEpkKfV_hUXI7c/

Effectively, Flipper can generate a token which is then used by the client to authenticate.

This diff contains the changes required to generate, obtain, and validate authentication tokens from clients connecting to flipper over TCP connections.

The token itself is a JWT token. JWT was chosen because it is a simple industry standard which offers three features which can immediately benefit us:

- Expiration handling. No need for Flipper to store this information anywhere.
- Payload. Payload can be used to push any data we deem relevant i.e. unix username.
- Signing. Signed and verified using the same server key pair which is already in place for certificate exchange.

Additionally, the token is stored in the Flipper static folder. This ensures that the browser and PWA clients have access to it.

Reviewed By: mweststrate

Differential Revision: D45179654

fbshipit-source-id: 6761bcb24f4ba30b67d1511cde8fe875158d78af
2023-05-05 07:52:13 -07:00
Andrey Goncharov
d987e36c62 Add a single place to initialize Flipper utilitary folders
Summary: We have several folders Flipper uses that sometimes we forget to create before Flipper starts. With this diff we have a single place to initialise the necessary folder structure.

Reviewed By: lblasa

Differential Revision: D37036601

fbshipit-source-id: f945f2bfdfc6be24ba87bd4b13c7fcef3fd74451
2022-06-10 06:38:50 -07:00
Andrey Goncharov
b8dda9b0a7 Create .flipper/certs folder when necessary
Reviewed By: passy

Differential Revision: D36346367

fbshipit-source-id: 290a4a64ad3266f282f13074b2161d988a2bf2cc
2022-05-13 03:19:47 -07:00
Andrey Goncharov
b1f19ecd68 Extract certificate utils
Summary: Extract utilities for certificate server-side certificate handling

Reviewed By: lawrencelomax

Differential Revision: D33820263

fbshipit-source-id: 21f1a9ed5f3b83b8350151bdf6d8862aa0b18e8f
2022-02-02 03:07:00 -08:00