-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[identity] configurable no password authentication
- Loading branch information
Showing
7 changed files
with
92 additions
and
12 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
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
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
9 changes: 9 additions & 0 deletions
9
...identity/priv/repo/migrations/20241130000259_add_check_password_to_identity_providers.exs
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,9 @@ | ||
defmodule BorutaIdentity.Repo.Migrations.AddCheckPasswordToIdentityProviders do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:identity_providers) do | ||
add :check_password, :boolean, null: false, default: true | ||
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 |
---|---|---|
|
@@ -543,13 +543,21 @@ defmodule BorutaIdentity.AccountsTest do | |
identity_provider: insert(:identity_provider, confirmable: true) | ||
) | ||
|
||
no_password_client_identity_provider = | ||
BorutaIdentity.Factory.insert( | ||
:client_identity_provider, | ||
identity_provider: insert(:identity_provider, check_password: false) | ||
) | ||
|
||
client_identity_provider = BorutaIdentity.Factory.insert(:client_identity_provider) | ||
|
||
{:ok, | ||
backend: client_identity_provider.identity_provider.backend, | ||
client_id: client_identity_provider.client_id, | ||
confirmable_backend: confirmable_client_identity_provider.identity_provider.backend, | ||
confirmable_client_id: confirmable_client_identity_provider.client_id} | ||
confirmable_client_id: confirmable_client_identity_provider.client_id, | ||
no_password_backend: no_password_client_identity_provider.identity_provider.backend, | ||
no_password_client_id: no_password_client_identity_provider.client_id} | ||
end | ||
|
||
test "returns an error with nil client_id" do | ||
|
@@ -719,6 +727,29 @@ defmodule BorutaIdentity.AccountsTest do | |
assert session_token | ||
end | ||
|
||
test "authenticates the user with no password", %{no_password_client_id: client_id, no_password_backend: backend} do | ||
context = :context | ||
username = "[email protected]" | ||
authentication_params = %{email: username} | ||
|
||
assert {:user_authenticated, ^context, | ||
%User{ | ||
username: ^username, | ||
backend: ^backend, | ||
last_login_at: last_login_at | ||
}, | ||
session_token} = | ||
Accounts.create_session( | ||
context, | ||
client_id, | ||
authentication_params, | ||
DummySession | ||
) | ||
|
||
assert last_login_at | ||
assert session_token | ||
end | ||
|
||
test "does not create multiple users accross multiple authentications", %{ | ||
client_id: client_id, | ||
backend: backend | ||
|