Skip to content

Commit

Permalink
Fix #20313: Allow CompositeAuth auth methods to use their own request…
Browse files Browse the repository at this point in the history
… and response if defined

Co-authored-by: Stefano Mtangoo <[email protected]>
  • Loading branch information
mtangoo and Stefano Mtangoo authored Jan 17, 2025
1 parent a05f60b commit d146307
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Yii Framework 2 Change Log
- Bug #20300: Clear stat cache in `FileCache::setValue()` (rob006)
- Enh #20306: Add new `yii\helpers\ArrayHelper::flatten()` method (xcopy)
- Bug #20308: Allow CompositeAuth auth methods to use their own user if defined (mtangoo)
- Bug #20313: Allow CompositeAuth auth methods to use their own request and response if defined (mtangoo)

2.0.51 July 18, 2024
--------------------
Expand Down
14 changes: 14 additions & 0 deletions framework/filters/auth/CompositeAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ public function authenticate($user, $request, $response)
$user = $authUser;
}

$authRequest = $auth->request;
if ($authRequest != null && !$authRequest instanceof \yii\web\Request) {
throw new InvalidConfigException(get_class($authRequest) . ' must implement yii\web\Request');
} elseif ($authRequest != null) {
$request = $authRequest;
}

$authResponse = $auth->response;
if ($authResponse != null && !$authResponse instanceof \yii\web\Response) {
throw new InvalidConfigException(get_class($authResponse) . ' must implement yii\web\Response');
} elseif ($authResponse != null) {
$response = $authResponse;
}

$identity = $auth->authenticate($user, $request, $response);
if ($identity !== null) {
return $identity;
Expand Down

0 comments on commit d146307

Please sign in to comment.