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
Tprod 296 Authentication refactoring needed for Symfony 5 #11057
Conversation
We'll see what this breaks
…ere is no need for authorization New feature of Symfony 4.4
… different shapes
…ate as there is no need for extending it
…y so many tests are failing
…t's breaking the tests
…ng mail from config
Codecov Report
@@ Coverage Diff @@
## 5.x #11057 +/- ##
============================================
+ Coverage 48.99% 49.15% +0.15%
Complexity 35399 35399
============================================
Files 2147 2147
Lines 105609 105637 +28
============================================
+ Hits 51744 51921 +177
+ Misses 53865 53716 -149
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked with the regular user login but unfortunately between the instructions in the linked PR and the developer docs I was not able to fathom how to test the OAuth2 login or SSO. So someone will need to check both of those (and we should improve our docs on this!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Form login and the oAuth2 worked as expected.
POST https://mautic.mautic/oauth/v2/token
Accept: application/json
Content-Type: application/json
{ "grant_type": "client_credentials", "client_id": "<redacted>", "client_secret": "<redacted>" }
HTTP/1.1 200 OK
...
{
"access_token": "ODdmNzk2ODBmYTlkM2YzMzViZDQxNjI4ZDNmYTQ0YjRmNmZlOTNkZDI5MjYyMzA4MzhlZjQwMWRlZTM3NjAxNg",
"expires_in": 3600,
"token_type": "bearer",
"scope": null
}
GET https://mautic.mautic/api/contacts
Accept: application/json
Authorization: Bearer ODdmNzk2ODBmYTlkM2YzMzViZDQxNjI4ZDNmYTQ0YjRmNmZlOTNkZDI5MjYyMzA4MzhlZjQwMWRlZTM3NjAxNg
HTTP/1.1 200 OK
...
{
"total": "14",
"contacts": {
"29": {
"isPublished": true,
.....
* Disabling the cookie service mocking for tests as it causes problems We'll see what this breaks * Functional tests for Oauth2 * The lazy anonymous mode prevents the session from being started if there is no need for authorization New feature of Symfony 4.4 * Removing deprecated interface from AuthenticationListener * Adding option to skip setting mock services in a test * Fixing test that was not asserting anyting useful * CS fixes * Fixing the flag condition * Backing up the strict type for providerKey as it seems it can come in different shapes * Making the class final and properties for AuthenticationListener private as there is no need for extending it * CS fix * Fixing several tests that were missing the table prefix * Trying to revert the change in Abstract test case to see if that's why so many tests are failing * CS fix * Oops, I meant to leave this line uncommented * CS fix * Trying if the lazy value is breaking the tests * Trying to run the new test in a new process * Yes! New process worked. Adding back what was removed to find out what's breaking the tests * Improving tests to print the response for debugging * Adding response content to the asssertion checks for debugging * Documenting the BC break about AuthenticationListener * Trying without enableReboot * Finally figured out why it was trying to install Mautic. It was missing mail from config
Description:
I started with this by looking what is the AuthenticationListener used for and found last changes coming from #9837 so I got an impression it is used for Oauth2 and wrote a test for it. It turns out it's not that related and the AuthenticationListener that needed refactoring is actually used for user login and SSO. Anyway, the test for Oauth2 is useful to have.
The changes needed to get rid of the deprecated ListenerInterface are actually nicely described in https://stackoverflow.com/questions/56438177/deprecated-the-listenerinterface-turn-your-listeners-into-callables-instead and if I'd follow that instead of trying to figure out the usage from git history and the code then it would save a lot of time.
This PR also changes configuration for the "anonymous" security option from
true
to'lazy'
. That is a new option since Symfony 4.4 described asSo I was hoping it will stop creating session cookies on those routes but it behaves the same as before.
Steps to test this PR: