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
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
26241cf5c0 Skip logging data for the 'upload-scibe-logs-event''
Summary:
Logging data for this event turnslogs into unreadable mess
{F789339377}

Reviewed By: lblasa

Differential Revision: D40978819

fbshipit-source-id: ac0894b2a490aa902180c50e7712b168211c7013
2022-11-04 08:23:44 -07:00
Andrey Goncharov
2a108854d2 Make flipper-server-client gracefully handle malformed messages
Summary: FlipperServerClient can use any socket to transfer the data. Since we do not control the socket, we cannot guarantee what comes out of it (hello, Jest E2E tunnel!). We need to handle unexpected messages gracefully.

Reviewed By: passy

Differential Revision: D40891384

fbshipit-source-id: 6f873037aa49bac3fc4c09fa49483cdec537ae40
2022-11-03 06:57:17 -07:00
Andrey Goncharov
60a439ef7b Remove window refernce from flipper-server-client
Summary: Remove `window` reference to use flipper-server-client in NodeJS context (windows is not defined there)

Reviewed By: passy

Differential Revision: D40859805

fbshipit-source-id: 23415f9d504e4dbba4035b942c73add86edf02de
2022-11-03 06:57:17 -07:00
Andrey Goncharov
226ccf91f6 Create flipper-server-client package
Summary:
FlipperServerClient is a useful abstraction for any JS-based client of headless Flipper. No need to bundle it with flipper-frontend-core, as the rest is not useful for external clients.
Currently, I am planning to add it to jest-e2e to send commands to Flipper

Reviewed By: lblasa

Differential Revision: D40765668

fbshipit-source-id: af48710bb15444ac1ecd649fe9a2ab252f3088f3
2022-10-31 04:26:43 -07:00