-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only allow oauth login against current login method
There's probably a needed frontend change here too, but can handle that after the fact
- Loading branch information
1 parent
e551c8d
commit 632d1d6
Showing
7 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule Core.Schema.Validations do | ||
import Ecto.Changeset | ||
|
||
@url_regex ~r/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/ | ||
|
||
def reject_urls(cs, field) do | ||
validate_change(cs, field, fn | ||
_, val when is_binary(val) -> | ||
case String.match?(val, @url_regex) do | ||
true -> [{field, "cannot contain urls"}] | ||
_ -> [] | ||
end | ||
_, _ -> [{field, "must be a string"}] | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,13 @@ defmodule Core.Services.Cloud do | |
|> add_operation(:cluster, fn _ -> select_cluster(attrs[:cloud], attrs[:region]) end) | ||
|> add_operation(:postgres, fn _ -> select_roach(attrs[:cloud]) end) | ||
|> add_operation(:sa, fn _ -> | ||
Accounts.create_service_account(%{name: "#{name}-cloud-sa", email: "#{name}[email protected]"}, user) | ||
Accounts.create_service_account(%{ | ||
name: "#{name}-cloud-sa", | ||
email: "#{name}[email protected]", | ||
impersonation_policy: %{ | ||
bindings: [%{user_id: user.id}] | ||
} | ||
}, user) | ||
end) | ||
|> add_operation(:token, fn %{sa: sa} -> Users.create_persisted_token(sa) end) | ||
|> add_operation(:install, fn %{sa: sa} -> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,10 @@ defmodule Core.Services.AccountsTest do | |
assert account.name == "updated" | ||
end | ||
|
||
test "cannot put urls in names", %{user: user} do | ||
{:error, _} = Accounts.update_account(%{name: "https://evil.com"}, user) | ||
end | ||
|
||
test "if billing address is updated, it will update the stripe customer", %{user: user, account: account} do | ||
{:ok, _} = update_record(account, %{billing_customer_id: "strp"}) | ||
me = self() | ||
|
@@ -335,7 +339,7 @@ defmodule Core.Services.AccountsTest do | |
assert invite.user_id == user.id | ||
end | ||
|
||
test "nonroot users can create group members", %{account: account} do | ||
test "nonroot users cannot create group members", %{account: account} do | ||
{:error, _} = Accounts.create_invite(%{email: "[email protected]"}, insert(:user, account: account)) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,10 @@ defmodule Core.Services.CloudTest do | |
assert refetch(cluster).count == 1 | ||
assert refetch(postgres).count == 1 | ||
|
||
sa = Core.Services.Users.get_user_by_email("[email protected]") | ||
%{impersonation_policy: %{bindings: [binding]}} = Core.Repo.preload(sa, [impersonation_policy: :bindings]) | ||
assert binding.user_id == user.id | ||
|
||
assert_receive {:event, %PubSub.ConsoleInstanceCreated{item: ^instance}} | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters