mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
checkpoint
This commit is contained in:
21
README.md
21
README.md
@@ -52,14 +52,31 @@ You'll need recent versions of the following tools installed:
|
||||
With the above installed, you should be able to navigate into the project root
|
||||
and just run:
|
||||
|
||||
```
|
||||
$ vagrant up
|
||||
```bash
|
||||
vagrant up
|
||||
```
|
||||
|
||||
This will download the VM base box, provision it with dependencies, bootstrap
|
||||
the FireGuard DB, launch the FireGuard Services, and print instructions for
|
||||
connecting to the Web UI.
|
||||
|
||||
## Creating Additional Users
|
||||
|
||||
FireGuard creates the first user for you upon installation and prints the
|
||||
credentials after `vagrant up` completes in the step above.
|
||||
|
||||
You may create additional users with the following command:
|
||||
|
||||
```bash
|
||||
sudo -u fireguard /opt/fireguard/bin/fireguard rpc 'FgHttp.Users.create_user(
|
||||
email: "USER_EMAIL",
|
||||
password: "USER_PASSWORD",
|
||||
password_confirmation: "USER_PASSWORD"
|
||||
)'
|
||||
```
|
||||
|
||||
This will create a user you can use to log into the Web UI.
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
|
||||
@@ -82,3 +82,11 @@
|
||||
shell: |
|
||||
cd /home/vagrant/fireguard
|
||||
dpkg -i fireguard_amd64.deb
|
||||
- name: Create user
|
||||
become: fireguard
|
||||
shell: |
|
||||
cd /home/vagrant/fireguard
|
||||
scripts/create_user.sh
|
||||
register: create_user
|
||||
- name: Display user credentials
|
||||
debug: msg="{{ create_user.stdout }}"
|
||||
|
||||
@@ -14,7 +14,13 @@ defmodule FgHttp.Users do
|
||||
|
||||
def get_user!(id), do: Repo.get!(User, id)
|
||||
|
||||
def create_user(attrs \\ %{}) do
|
||||
def create_user(attrs) when is_list(attrs) do
|
||||
attrs
|
||||
|> Enum.into(%{})
|
||||
|> create_user()
|
||||
end
|
||||
|
||||
def create_user(attrs) when is_map(attrs) do
|
||||
%User{}
|
||||
|> User.create_changeset(attrs)
|
||||
|> Repo.insert()
|
||||
|
||||
18
apps/fg_http/test/fg_http/users_test.exs
Normal file
18
apps/fg_http/test/fg_http/users_test.exs
Normal file
@@ -0,0 +1,18 @@
|
||||
defmodule FgHttp.UsersTest do
|
||||
use FgHttp.DataCase
|
||||
|
||||
alias FgHttp.Users
|
||||
alias FgHttp.Users.User
|
||||
|
||||
describe "users" do
|
||||
@valid_user [
|
||||
email: "admin@fireguard.dev",
|
||||
password: "test-password",
|
||||
password_confirmation: "test-password"
|
||||
]
|
||||
|
||||
test "create_user" do
|
||||
assert {:ok, %User{} = _user} = Users.create_user(@valid_user)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
od=$(pwd)
|
||||
mkdir -p pkg/debian/opt
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
od=$(pwd)
|
||||
mix local.hex --force && mix local.rebar --force
|
||||
|
||||
14
scripts/create_user.sh
Executable file
14
scripts/create_user.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
email="$(openssl rand -hex 2)@fireguard.local"
|
||||
password="$(openssl rand -base64 12)"
|
||||
/opt/fireguard/bin/fireguard eval "FgHttp.Users.create_user(
|
||||
email: \"${email}\",
|
||||
password: \"${password}\",
|
||||
password_confirmation: \"${password}\"
|
||||
)"
|
||||
|
||||
echo "FireGuard user created! Save this information becasue it will NOT be shown again."
|
||||
echo "Email: ${email}"
|
||||
echo "Password: ${password}"
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
# migrate DB
|
||||
fg_http/bin/fg_http eval "FgHttp.Release.migrate"
|
||||
|
||||
Reference in New Issue
Block a user