-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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 user if defined #20308
Conversation
mtangoo
commented
Jan 13, 2025
•
edited by samdark
Loading
edited by samdark
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ❌ |
Breaks BC? | ❌ |
Fixed issues | #20238 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20308 +/- ##
============================================
- Coverage 64.84% 64.84% -0.01%
- Complexity 11424 11427 +3
============================================
Files 431 431
Lines 37172 37177 +5
============================================
+ Hits 24106 24109 +3
- Misses 13066 13068 +2 ☔ View full report in Codecov by Sentry. |
I see this was discussed and proposed to be changed in 2.2. Are we doing this in 2.0 anyway? |
@bizley I don't see any compatibility issues with this change. Are there any? |
I think in 2.2 there will be a need to look at the API design itself and if necessary make breaking change. This is a "painkiller" approach to just fix the issue without any breaking changes |
With this change user set in the inner auth method will be used for it, now we are using user set in the composite auth. |
Only if is set. Otherwise it works as it used to! |
Yes, but now even if user is set in one of the methods it is ignored. |
Isn't that the purpose of defining user in auth method, that you want it to override anything else defined? |
I agree but this is BC break as was stated in #20238 |
I take it as a bug, because otherwise what is the point of an API allowing devs to pass user object of their choice if it ends up being discarded? IMO, this is a bug that wasn't uncovered for so long. |
I view it as a bug as well. I can't imagine a good scenario where this override is defined but everything works because it's ignored. |
In my opinion we should fix the bugs that appear in Yii2, what's the point of not doing BC and having bugs is my two cents. |
I agreed with @schmunk42 on this being potentially problematic. I would like to have it change anyway. If you want to proceed with the change I don't mind. |
I agree with you on this needing a change. But this can be discussed and changed in 2.2, I guess |
Alright. Let's have it. Thanks, @mtangoo |
In my original message, I also mentioned $request and $response having the same fate as the $user. If I remember correctly (sorry, can't study the code in detail right now), $request and $response could also be configured for different auth methods, but they were ignored in CompositeAuth. Was this changed/fixed or pushed back? It was not an issue that I ran into. I just ran into the $user issue, but looking back then, both $request and $response were ignored if they were set/defined in authorization methods. |
Can you explain how do you pass a different request or response object in Yii2. Can you provide a use case of that scenario? |
For example, let's say I want to use HttpBasicAuth and HttpBearerAuth in CompositeAuth. Each of HttpBasicAuth and HttpBearerAuth allows separate configuration of $response and $request components in themselves, which is expected. However, these $response and $request configured in HttpBasicAuth and HttpBearerAuth will not be respected by CompositeAuth. Their configuration is not passed into CompositeAuth, because CompositeAuth defines its own $request and $response (or null), and by default CompositeAuth will take $response and $request from the app config and not from Auth components passed into it. |
Side comment, which I want to make sure we do not overlook and kill this class all together. I don't think it is emphasized enough in the documentation. The cool thing about CompositeAuth is not that it may be simplifying several methods of authentication, but most importantly it allows OR logic. If you were to simply list the AuthMethods in controller that will create AND logic, which is probably not what you want. |
I will make a followup PR to finalize the overlooked part |
Yii have a lot of parts that are cool and underutilized by devs. Partly is because many ofnits devs don't write or make a lot of videos tuts |
Maybe we can have an AI make video tutorials from written documentation. 😆 |
May be. But a touch of humanity always beats the robots 😉 |