firezone icon indicating copy to clipboard operation
firezone copied to clipboard

REST API

Open jamilbk opened this issue 3 years ago • 3 comments

v1 REST API to manage Users and Configuration.

jamilbk avatar Aug 08 '22 22:08 jamilbk

Hello @jamilbk ! I am curious, what is the idea for the API in terms of stack? Rust/Elixir as well? Looking forward to hearing back from you.

iamleandro avatar Sep 10 '22 19:09 iamleandro

@iamleandro REST API will be in Elixir and live with the rest of our Phoenix app.

jamilbk avatar Sep 10 '22 19:09 jamilbk

I am not familiar with Elixir (yet), but I liked the idea behind firezone. I am quite comfortable building REST APIs but I wouldn't know how to structure the files, which imports I would need and so on. Will sub on this one and use it as an opportunity to learn a new stack.

I'm assuming it will be living under /apps e.g. "fz-api" or something?

Anyways, in the meantime I can check on https://github.com/firezone/elixir-phoenix-realworld-example-app. :)

iamleandro avatar Sep 10 '22 19:09 iamleandro

I'm hoping that allowing devices to be created with the rest api. would also allow importing existing devices public key, preshared key, and ip. I thought I could do it with postgres directly, but the preshared key field is encrypted. So for my org to migrate to firezone i'm blocked with waiting until an rest api supports it, or learning elixr.

I'd like to be able to import ip, presharedkey, and public key per user. I'm wanting to replace an algo wireguard setup without changing the configs on the client side machine.

jbtule avatar Oct 05 '22 16:10 jbtule

@jbtule Definitely a hack, but try this:

/opt/firezone/embedded/service/firezone/bin/firezone rpc 'IO.inspect(FzHttp.Devices.create_device(%{user_id: "integer_user_id", name: "...", ...}))'

You can see more fields for creating a device here.

jamilbk avatar Oct 05 '22 18:10 jamilbk

@jamilbk I used it to setup one user, it's looking good in the admin interface, so I'll continue with my migration and generate a shell script of all my users. Thanks!

jbtule avatar Oct 05 '22 20:10 jbtule

@jamilbk That worked! Thank you for that hack! We replaced algo with firezone in place!

jbtule avatar Oct 07 '22 14:10 jbtule

Unfortunately this didn't quite make it into 0.6.0. It'll be coming soon as part of 0.7.0.

jamilbk avatar Oct 12 '22 18:10 jamilbk