Are there any API(s) to create users and devices in-order to automate the process?
@remy The REST API is still under development, but for the time being you can create Users and Devices by rpcâing into the functions directly like so:
Create user
/opt/firezone/embedded/service/firezone/bin/firezone rpc 'FzHttp.Users.create_user(%{"email" => "foobar@example.com", "password" => "password_here", "password_confirmation" => "password_here"})'
Create device for user (must know user_id and generate psk and keypair beforehand)
/opt/firezone/embedded/service/firezone/bin/firezone rpc 'FzHttp.Devices.create_device(%{"user_id" => 36, "public_key" => "H4P2H2LvtVWa+MZw/GD6dUkjF1HstCdr2HXxqMzY=", "preshared_key" => "dHN1zuRd/PemzBDeYQqMsVTyHSNoTsmJQ=", "name" => "DEVICE_NAME"})'
@jamil, is it possible to provide the command to check if the user and the device exists before they are created?
I tried with /opt/firezone/embedded/service/firezone/bin/firezone rpc 'FzHttp.Users.get_by_email("user@localhost.local")'
but it give no output, actual user dose exists.
Yep, Try IO.inspect(FzHttp.Users.get_by_email(âŚ))
in order to format the output
@jamil, thanks thats working
/opt/firezone/embedded/service/firezone/bin/firezone rpc 'IO.inspect(FzHttp.Users.get_by_email("user@localhost.local"))'
/opt/firezone/embedded/service/firezone/bin/firezone rpc 'IO.inspect(FzHttp.Devices.list_devices(<device_id>))'
@jamil , is it possible to add validation when adding device from CLI command to check if the public key and pre-shared keys are valid? I added wrong key add Phoenix crashed, had to delete the user from database and then restart firezone
@remy Thanks for the suggestion! Yeah, weâre changing the way keys are stored in the DB as part of 0.4.0
and this will be fixed then.
api $ curl -i
-X POST âhttps://{firezone_host}/v0/devicesâ
-H âContent-Type: application/jsonâ
-H âAuthorization: Bearer {api_token}â
âdata-binary @- << EOF
{
âdeviceâ: {
âallowed_ipsâ: [
â0.0.0.0/0â,
â::/0â,
â1.1.1.1â
],
âdescriptionâ: âcreate-descriptionâ,
âdnsâ: [
â9.9.9.8â
],
âendpointâ: â9.9.9.9â,
âipv4â: â100.64.0.2â,
âipv6â: âfd00::2â,
âmtuâ: 999,
ânameâ: âcreate-nameâ,
âpersistent_keepaliveâ: 9,
âpreshared_keyâ: âCHqFuS+iL3FTog5F4Ceumqlk0CU4Cl/dyUP/9F9NDnI=â,
âpublic_keyâ: âCHqFuS+iL3FTog5F4Ceumqlk0CU4Cl/dyUP/9F9NDnI=â,
âuse_default_allowed_ipsâ: false,
âuse_default_dnsâ: false,
âuse_default_endpointâ: false,
âuse_default_mtuâ: false,
âuse_default_persistent_keepaliveâ: false,
âuser_idâ: â95138a8e-c89f-41b4-b62c-a5b8c23a0b8câ
}
}create users and devices
But I couldnât connect to Firezone using the device I created through client configuration Only manually generated configurations through Firezoneâs UI page can connect successfully ďź