Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CompositeAuth auth methods to use their own request and respon… #20313

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
$user = $authUser;
}

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

Check warning on line 98 in framework/filters/auth/CompositeAuth.php

View check run for this annotation

Codecov / codecov/patch

framework/filters/auth/CompositeAuth.php#L98

Added line #L98 was not covered by tests
} elseif ($authRequest != null) {
$request = $authRequest;

Check warning on line 100 in framework/filters/auth/CompositeAuth.php

View check run for this annotation

Codecov / codecov/patch

framework/filters/auth/CompositeAuth.php#L100

Added line #L100 was not covered by tests
}

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

Check warning on line 105 in framework/filters/auth/CompositeAuth.php

View check run for this annotation

Codecov / codecov/patch

framework/filters/auth/CompositeAuth.php#L105

Added line #L105 was not covered by tests
} elseif ($authResponse != null) {
$response = $authResponse;

Check warning on line 107 in framework/filters/auth/CompositeAuth.php

View check run for this annotation

Codecov / codecov/patch

framework/filters/auth/CompositeAuth.php#L107

Added line #L107 was not covered by tests
}

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