Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Respect realm when logging in
Browse files Browse the repository at this point in the history
This change uses the username from the ccache to ensure we include the correct realm when logging in, enabling cross-realm login.

Fixes: #114-logging-in-using-realm-ends-ip-with-the-wrong-upn
  • Loading branch information
AlexGodbehere committed Mar 20, 2024
1 parent 61de77b commit 3d3328f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/Domain/Auth/Actions/AuthenticateUserAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,17 @@ public function execute(string $username, string $password)
}
}

// Use the username from the ccache to ensure we include the correct realm
$username = $ccache->getPrincipal();

// Get the local user with this username (null if they don't exist)
$user = User::whereUsername($username . '@' . config('manager.realm'))->first();
$user = User::whereUsername($username)->first();

// If the user doesn't exist then create them
if (!$user) {
$user = User::create(
[
'username' => $username . '@' . config('manager.realm'),
'username' => $username,
]
);
}
Expand Down

0 comments on commit 3d3328f

Please sign in to comment.