Commit Graph

31 Commits

Author SHA1 Message Date
Andrew Dryga
a211f96109 feat(portal): Broadcast state changes to connected clients and gateways (#2240)
# Gateways
- [x] When Gateway Group is deleted all gateways should be disconnected
- [x] When Gateway Group is updated (eg. routing) broadcast to all
affected gateway to disconnect all the clients
- [x] When Gateway is deleted it should be disconnected
- [x] When Gateway Token is revoked all gateways that use it should be
disconnected

# Relays
- [x] When Relay Group is deleted all relays should be disconnected
- [x] When Relay is deleted it should be disconnected
- [x] When Relay Token is revoked all gateways that use it should be
disconnected

# Clients
- [x] Remove Delete Client button, show clients using the token on the
Actors page (#2669)
- [x] When client is deleted disconnect it
- [ ] ~When Gateway is offline broadcast to the Clients connected to it
it's status~
- [x] Persist `last_used_token_id` in Clients and show it in tokens UI

# Resources
- [x] When Resource is deleted it should be removed from all gateways
and clients
- [x] When Resource connection is removed it should be deleted from
removed gateway groups
- [x] When Resource is updated (eg. traffic filters) all it's
authorizations should removed

# Authentication
- [x] When Token is deleted related sessions are terminated
- [x] When an Actor is deleted or disabled it should be disconnected
from browser and client
- [x] When Identity is deleted it's sessions should be disconnected from
browser and client
- [x] ^ Ensure the same happens for identities during IdP sync
- [x] When IdP is disabled act like all actors for it are disabled?
- [x] When IdP is deleted act like all actors for it are deleted?

# Authorization
- [x] When Policy is created clients that gain access to a resource
should get an update
- [x] When Policy is deleted we need to all authorizations it's made
- [x] When Policy is disabled we need to all authorizations it's made
- [x] When Actor Group adds or removes a user, related policies should
be re-evaluated
- [x] ^ Ensure the same happens for identities during IdP sync

# Settings
- [x] Re-send init message to Client when DNS settings change

# Code
- [x] Crear way to see all available topics and messages, do not use
binary topics any more

---------

Co-authored-by: conectado <gabrielalejandro7@gmail.com>
2024-02-01 11:02:13 -06:00
Andrew Dryga
2e92174697 Update script to rotate global relays token 2024-01-16 19:09:28 -06:00
Andrew Dryga
832fc3f2e3 Implement rest of TODOs after token refactoring (#3160)
- [x] Introduce api_client actor type and code to create and
authenticate using it's token
- [x] Unify Tokens usage for Relays and Gateways
- [x] Unify Tokens usage for magic links


Closes #2367
Ref #2696
2024-01-16 21:39:00 +00:00
Andrew Dryga
ce932ffd90 fix(portal): Remove token provider and implement separate flow for service accounts (#3146)
Closes #2501
2024-01-10 10:33:10 -06:00
Andrew Dryga
ed5437c881 security(portal): Rework auth tokens (#2696)
- [x] make sure that session cookie for client is stored separately from
session cookie for the portal (will close #2647 and #2032)
- [x] #2622
- [ ] #2501
- [ ] show identity tokens and allow rotating/deleting them (#2138)
- [ ] #2042
- [ ] use Tokens context for Relays and Gateways to remove duplication
- [x] #2823
- [ ] Expire LiveView sockets when subject is expired
- [ ] Service Accounts UI is ambiguous now because of token identity and
actual token shown
- [ ] Limit subject permissions based on token type

Closes #2924. Now we extend the lifetime for client tokens, but not for
browsers.
2024-01-09 13:36:21 -06:00
Jamil
c0904aa96f Update README.md
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-15 17:15:55 -08:00
Jamil
3773d5f79d Update README.md
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-15 17:15:11 -08:00
Andrew Dryga
52b284abd9 Terraform improvements for production (#2873) 2023-12-11 19:41:01 -06:00
Jamil
786e156337 Elixir/domain ops (#2837)
Adds a helper method we can call from a live IEX to provision an account
when signups are disabled.
2023-12-10 01:35:48 +00:00
Jamil
845707bd09 Update README.md
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-08 12:27:21 -05:00
Gabi
8e34457340 Add support for DNS sudomains (#2735)
This PR changes the protocol and adds support for DNS subdomains, now
when a DNS resource is added all its subdomains are automatically
tunneled too. Later we will add support for `*.domain` or `?.domain` but
currently there is an Apple split tunnel implementation limitation which
is too labor-intensive to fix right away.

Fixes #2661 

Co-authored-by: Andrew Dryga <andrew@dryga.com>
2023-12-08 00:16:42 -05:00
Andrew Dryga
af5cc38f9e Pick latest-versioned gateways (#2739)
Closes #2733
2023-11-30 11:52:24 -06:00
Jamil
8ad82b515e "Magic Link" -> "Email" (#2731)
Updates user-facing terminology to `One-Time Password` to more
accurately reflect this sign in method and match docs more consistently

Refs #2688 
Refs #2021
2023-11-28 23:58:50 +00:00
Andrew Dryga
d1d07e8401 Hotfix merged typos, Sign In form content, Sign Up email content (#2645)
I fixed a few typos that slipped in in the last UX PR. Also a few minor
changes:

Sign In as a client doesn't show the "client" link in the bottom any
more:
<img width="1728" alt="Screenshot 2023-11-14 at 13 46 24"
src="https://github.com/firezone/firezone/assets/1877644/7226078c-7f66-41b5-9fd4-e6e44b56fd35">

Extra ---or--- separator is removed when there are no recently used
accounts:
<img width="1728" alt="Screenshot 2023-11-14 at 13 46 29"
src="https://github.com/firezone/firezone/assets/1877644/c2463ca5-0967-4fe7-ac60-5f5179ea30d8">

Emails send after you sign up don't include sign in link right away,
just a link to a form so that you won't loose in in future. Addresses
"Session token is expired/incognito windows" in #2631
<img width="1728" alt="Screenshot 2023-11-14 at 14 32 30"
src="https://github.com/firezone/firezone/assets/1877644/4f6d4c79-b5ed-448a-9915-2616ed71c9b9">

I've allowed email token to be used along with magic link when signing
in as @jefferenced requested multiple times:
<img width="1728" alt="Screenshot 2023-11-14 at 14 23 58"
src="https://github.com/firezone/firezone/assets/1877644/8b9b5afe-5c65-4893-b6ef-107a0b683c31">
<img width="1728" alt="Screenshot 2023-11-14 at 14 24 50"
src="https://github.com/firezone/firezone/assets/1877644/c02db5df-5158-4bf3-93ff-80d9d6c82cbe">

Closes #2299
2023-11-14 14:57:16 -06:00
Andrew Dryga
33ab23b636 Cleanup UX and fix a bunch of TODOs (#2641)
This PR cleans up a lot of TODO and some issues I've discovered while
fixing them, there are _a few_ UI changes.

We show `(you)` next to your name on the actor view page, where
`Profile` link goes from the dropdown menu:
<img width="1728" alt="Screenshot 2023-11-13 at 19 05 35"
src="https://github.com/firezone/firezone/assets/1877644/f52b2531-e3be-4d3a-a587-4f9f54ca2c49">

Relays were way behind Gateways in terms of view code, so I changed them
to be exactly the same:
<img width="1728" alt="Screenshot 2023-11-13 at 18 54 39"
src="https://github.com/firezone/firezone/assets/1877644/a9f0905d-80d2-4e91-a744-c4baf7ad4a7c">

We also show authorizations on the Actor page because previously to find
"what this user did" you had to go through all user clients
individually:
<img width="1728" alt="Screenshot 2023-11-13 at 18 54 27"
src="https://github.com/firezone/firezone/assets/1877644/02ada445-e175-427e-99de-f9fa5bdd5aab">

I've noticed there is some confusion around sign-in slugs so I added a
home page where you can use ID or slug to get the in link (not all the
clients will know you need to put that in the URL) and recently used
accounts:
<img width="1728" alt="Screenshot 2023-11-13 at 18 54 06"
src="https://github.com/firezone/firezone/assets/1877644/ccfb9198-ed1f-4b3e-a26f-b76bab24243c">

Buttons to copy the code are more visible now, I've used our accent
color but am open to better ideas:
<img width="1728" alt="Screenshot 2023-11-13 at 19 10 29"
src="https://github.com/firezone/firezone/assets/1877644/a2c0658e-1003-409b-b5ad-d5d3ade60a10">

When code is copied it's also more visible:
<img width="699" alt="Screenshot 2023-11-13 at 19 11 41"
src="https://github.com/firezone/firezone/assets/1877644/62e793d2-d760-4aa7-9a42-92a6bbfcbf52">

We also do not redirect from that page automatically, but the large
button becomes green with the text changed:
<img width="660" alt="Screenshot 2023-11-13 at 19 12 11"
src="https://github.com/firezone/firezone/assets/1877644/780dcde3-8018-4405-91e5-984288431ec1">
2023-11-14 13:02:21 -06:00
Andrew Dryga
835c278a34 Add guide to rotate relay token 2023-10-31 16:10:49 -06:00
bmanifold
01f7839d0f Update API Upstream DNS address encoding (#2534)
Why:

* The portal was not able to properly JSON encode the Clients Upstream
DNS struct.
2023-10-31 06:37:07 +00:00
Andrew Dryga
6bfab7e376 Fix outdated examples in elixir's README.md 2023-10-19 23:14:16 -06:00
Andrew Dryga
37fc412ff3 Check websocket origin (#2192) 2023-09-29 12:02:54 -06:00
Andrew Dryga
e635ee3774 Properly set parent span ids for phoenix channels (#2101) 2023-09-20 22:21:34 -06:00
Andrew Dryga
86f04bff63 Trace api app and finish file renames (#2069) 2023-09-14 00:24:40 -06:00
Andrew Dryga
85b4aba9bc Rename Devices to Clients in Elixir app (#2008)
Renaming it back to clients to reflect service accounts and headless
clients use cases in the terminology. Such a rename will be very painful
on live data so better if we do it early on.

---------

Co-authored-by: Jamil Bou Kheir <jamilbk@users.noreply.github.com>
2023-09-13 12:37:27 +00:00
Andrew Dryga
8398e3013b Protect the magic links from account spoofing (#1990)
Closes https://github.com/firezone/product/issues/644
2023-09-07 18:23:33 -06:00
Jamil
68b1955dd0 fix(portal): revert check_origin: :conn for the WebSocket connection on web (#1952)
Looks like it broke the staging WS connections. Getting a failure of
Liveview socket connection on `app.firez.one`:

```
insertId: 1o7nymzg12jh1k5
jsonPayload:
  cos.googleapis.com/container_id: 89b4633e81432e43dfbaa3957324fd5ead3f2362737bac84648a8f839b6eb16c
  cos.googleapis.com/container_name: klt-web-cpap
  cos.googleapis.com/stream: stdout
  message:
    domain:
    - elixir
    erl_level: error
    logging.googleapis.com/sourceLocation:
      file: lib/phoenix/socket/transport.ex
      function: Elixir.Phoenix.Socket.Transport.check_origin/5
      line: 344
    message: |+
      Could not check origin for Phoenix.Socket transport.

      Origin of the request: https://app.firez.one

      This happens when you are attempting a socket connection to
      a different host than the one configured in your config/
      files. For example, in development the host is configured
      to "localhost" but you may be trying to access it from
      "127.0.0.1". To fix this issue, you may either:

        1. update [url: [host: ...]] to your actual host in the
           config file for your current environment (recommended)

        2. pass the :check_origin option when configuring your
           endpoint or when configuring the transport in your
           UserSocket module, explicitly outlining which origins
           are allowed:

              check_origin: ["https://example.com",
                             "//another.com:888", "//other.com"]

    severity: ERROR
    time: '2023-08-26T21:24:36.002Z'
  time: '2023-08-26T21:24:36.002628434Z'
logName: projects/firezone-staging/logs/cos_containers
receiveTimestamp: '2023-08-26T21:24:36.402398476Z'
resource:
  labels:
    instance_id: '8218473336234347240'
    project_id: firezone-staging
    zone: us-east1-d
  type: gce_instance
timestamp: '2023-08-26T21:24:36.002628434Z'
```
2023-08-28 19:09:37 +00:00
Jamil
54e1a79a50 fix(ios): portal connectivity and tunnel setup (#1927)
This PR fixes issues with the iOS client connecting to the portal and
setting up the tunnel.

- portal IPv6 unique-local prefix typo
- Use `rustls-webpki-roots` instead of `rustls-native-roots` for tokio
tungstenite since the latter [only supports macOS, Linux, and
Windows](https://github.com/rustls/rustls-native-certs) while the former
seems to work on all platforms(?)
- Remove Multipath TCP entitlement for iOS since it's not relevant for
us.

@conectado After this is merged, we _almost_ have a working tunnel on
iOS. I believe the error we're hitting now is the 4-byte address family
header that we need to add and strip from each packet written to / read
from the tunnel. See below log for sample output when attempting to
connect to the `HTTPbin` resource:

```
dev.firezone.firezone.network-extension	packet-tunnel	debug	16:10:13.401705-0700	FirezoneNetworkExtensioniOS	Adapter state changed to: tunnelReady
dev.firezone.firezone.network-extension	packet-tunnel	debug	16:10:13.401731-0700	FirezoneNetworkExtensioniOS	Beginning path monitoring
com.apple.network	path	default	16:10:13.402211-0700	FirezoneNetworkExtensioniOS	nw_path_evaluator_start [1ACDE975-615B-4557-BF7C-678F3594452E <NULL> generic, multipath service: 1, attribution: developer]
	path: satisfied (Path is satisfied), interface: en0[802.11], scoped, ipv4, ipv6, dns
com.apple.network	path	info	16:10:13.402235-0700	FirezoneNetworkExtensioniOS	nw_path_evaluator_call_update_handler [1ACDE975-615B-4557-BF7C-678F3594452E] scheduling update
com.apple.network	path	info	16:10:13.402261-0700	FirezoneNetworkExtensioniOS	nw_path_evaluator_call_update_handler_block_invoke [1ACDE975-615B-4557-BF7C-678F3594452E] delivering update
com.apple.network		debug	16:10:13.402286-0700	FirezoneNetworkExtensioniOS	nw_path_copy_interface_with_generation Cache miss for interface for index 3 (generation 4574)
com.apple.network		debug	16:10:13.402312-0700	FirezoneNetworkExtensioniOS	nw_path_copy_interface_with_generation Cache miss for interface for index 31 (generation 141)
dev.firezone.firezone.network-extension	packet-tunnel	debug	16:10:13.402363-0700	FirezoneNetworkExtensioniOS	Suppressing calls to disableSomeRoamingForBrokenMobileSemantics() and bumpSockets()
dev.firezone.firezone	connlib	debug	16:10:14.368105-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:15.369018-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:16.095618-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:16.370908-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:17.372035-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:18.373423-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:20.402863-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:24.381581-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:32.374566-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:10:38.137437-0700	FirezoneNetworkExtensioniOS	Text("{\"ref\":null,\"topic\":\"phoenix\",\"event\":\"phx_reply\",\"payload\":{\"status\":\"ok\",\"response\":{}}}")
dev.firezone.firezone	connlib	debug	16:10:38.137757-0700	FirezoneNetworkExtensioniOS	Phoenix status message
dev.firezone.firezone	connlib	debug	16:10:48.376339-0700	FirezoneNetworkExtensioniOS	Reading from iface 76 bytes
dev.firezone.firezone	connlib	debug	16:11:08.148369-0700	FirezoneNetworkExtensioniOS	Text("{\"ref\":null,\"topic\":\"phoenix\",\"event\":\"phx_reply\",\"payload\":{\"status\":\"ok\",\"response\":{}}}")
dev.firezone.firezone	connlib	debug	16:11:08.148654-0700	FirezoneNetworkExtensioniOS	Phoenix status message
```
2023-08-21 20:48:30 -07:00
Andrew Dryga
3a5877eaa3 Update protocol to reuse gateway connections (#1825)
This is a result of our discussion with @conectado, this PR will add a
new message type which will allow reusing existing connections to the
gateway to access a new resource. We will also change the LB strategy to
be aware of the current device connection so that we will not pick a
different one if we have a connected gateway that can serve a new
resource.

---------

Co-authored-by: conectado <gabrielalejandro7@gmail.com>
2023-08-10 12:41:06 -05:00
Andrew Dryga
9e17352fd6 Deploy relays (#1706)
Will finish once #1705 is merged and stable.

cc @thomaseizinger
2023-08-08 17:15:33 -05:00
Andrew Dryga
4bebccb6a0 Add docs section to see if everything is connected to the panel 2023-06-29 14:09:12 -06:00
Andrew Dryga
4154523b1c Add more websocat examples for connecting to a resource 2023-06-29 14:09:11 -06:00
Andrew Dryga
e039f1919d Hotifx seeds and references (#1689) 2023-06-23 15:09:52 -06:00
Andrew Dryga
d9eb2d18df Deployment for the cloud version (#1638)
TODO:
- [x] Cluster formation for all API and web nodes
- [x] Injest Docker logs to Stackdriver
- [x] Fix assets building for prod

To finish later:
- [ ] Structured logging:
https://issuetracker.google.com/issues/285950891
- [ ] Better networking policy (eg. use public postmark ranges and deny
all unwanted egress)
- [ ] OpenTelemetry collector for Google Stackdriver
- [ ] LoggerJSON.Plug integration

---------

Signed-off-by: Andrew Dryga <andrew@dryga.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-06-06 15:03:26 -06:00