-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
Remove oppressive words from code #1205
Conversation
Could you please rebase your PR and fix merge conflicts? |
Ok, let me a little bit more time, I prefer to make it BC too... |
Hey @greg0ire I don't know how to change this PR against 4.x branch instead of master branch. Is this possible? Or I must open a new PR? |
You can click on the Edit button on the top right (like changing the title) and then change the base branch. |
ab08848
to
9fcb163
Compare
@@ -178,7 +178,7 @@ public function configureGoogleAuthenticator($config, ContainerBuilder $containe | |||
} | |||
|
|||
$container->setParameter('sonata.user.google.authenticator.forced_for_role', $config['google_authenticator']['forced_for_role']); | |||
$container->setParameter('sonata.user.google.authenticator.ip_white_list', $config['google_authenticator']['ip_white_list']); | |||
$container->setParameter('sonata.user.google.authenticator.trusted_ip_list', $config['google_authenticator']['trusted_ip_list']); |
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.
This would be BC-break, people can still use the ip_white_list
option, so here we should also check if ip_white_list
exists and use it. A test verifying that this behavior still works would be nice.
PS: Is it possible to deprecate a parameter? 🤔 EDIT: deprecate a parameter in the container.
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.
@franmomu I've marked ip_white_list
as a deprecated parameter, is this enough?
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.
ip_white_list
is a configuration node. A container parameter is something else entirely. AFAIK You cannot deprecate it, but maybe I'm wrong. IMO @franmomu is right, you should define that parameter from whatever configuration node is defined in the config (after validating that one and only one of them is defined as I described above).
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.
What I meant (about the parameter deprecation in the container) is removing sonata.user.google.authenticator.ip_white_list
from the container is BC-break because someone can be using that parameter (it's unlikely, but you never know), if there is no way to deprecate a parameter in the container, an upgrade note I think it's enough and we will remove it on the next major version.
@@ -69,6 +69,9 @@ public function getConfigTreeBuilder() | |||
->scalarNode('server')->cannotBeEmpty()->end() | |||
->scalarNode('enabled')->defaultFalse()->end() | |||
->arrayNode('ip_white_list') | |||
->setDeprecated('The "%node%" option is deprecated. Use "trusted_ip_list" instead with the same values.') | |||
->end() | |||
->arrayNode('trusted_ip_list') |
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.
It would be great to throw an exception if both configuration nodes are defined. I'm not sure if it can be done here, if yes, that's great, if not you can do it in the extension.
So just to be clear because I didn't explain myself clearly, there are three issues right now:
$trustedIpList = $config['google_authenticator']['ip_white_list'] ?? $config['google_authenticator']['trusted_ip_list'];
$container->setParameter('sonata.user.google.authenticator.trusted_ip_list', trustedIpList);
$container->setParameter('sonata.user.google.authenticator.ip_white_list', trustedIpList); |
if (array_key_exists('ip_white_list', $config['google_authenticator']) && array_key_exists('trusted_ip_list', $config['google_authenticator'])) { | ||
throw new \RuntimeException('Please use only ``trusted_ip_list`` parameter. ``ip_white_list`` is deprecated.'); | ||
} | ||
if (array_key_exists('ip_white_list', $config['google_authenticator']) && !array_key_exists('trusted_ip_list', $config['google_authenticator'])) { | ||
$container->setParameter('sonata.user.google.authenticator.trusted_ip_list', $config['google_authenticator']['ip_white_list']); | ||
} else { |
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.
You should add a comment
// NEXT_MAJOR: Remove this checks and only set the trusted_ip_list.
That's how we deal todos.
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.
Done
$container->setParameter('sonata.user.google.authenticator.ip_white_list', $config['google_authenticator']['ip_white_list']); | ||
|
||
if (array_key_exists('ip_white_list', $config['google_authenticator']) && array_key_exists('trusted_ip_list', $config['google_authenticator'])) { | ||
throw new \RuntimeException('Please use only ``trusted_ip_list`` parameter. ``ip_white_list`` is deprecated.'); |
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.
This should be fixed by changing code, so let's use \LogicException
here
throw new \RuntimeException('Please use only ``trusted_ip_list`` parameter. ``ip_white_list`` is deprecated.'); | |
throw new \LogicException('Please use only ``trusted_ip_list`` parameter. ``ip_white_list`` is deprecated.'); |
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.
Also, why the double backticks?
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.
Seen in line 177 of the same class, I've tried to keep same notation (don't know if must be single or double backtick)
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.
This is neither markdown nor rst, don't know why it was contributed like this. IMO we should use double quotes…
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 think that now it's all fine tuned, but still getting an error during testing process. Can you help me to solve tests? I don't know very well how to do it.
Thx.
@@ -42,7 +42,7 @@ public function testDefault(): void | |||
], | |||
'google_authenticator' => [ | |||
'enabled' => false, | |||
'ip_white_list' => ['127.0.0.1'], | |||
'trusted_ip_list' => ['127.0.0.1'], |
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.
'trusted_ip_list' => ['127.0.0.1'], | |
'ip_white_list' => [], | |
'trusted_ip_list' => ['127.0.0.1'], |
Since ip_white_list
is still accepted, it will be in the default values, with this the test should be fixed.
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.
Fixed
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.
Can you please squash to a single commit ? If you dont know how to do it, we need to make sure we do a squash merge
Never done before, but I think that I can do it... let me try it |
Here is a guide:
|
90f76c7
ccf5d62
to
634faa2
Compare
Looks like you did it! One last thing: please format your commit message according to our rules :
Bad example :
Good example:
More details in CONTRIBUTING.md |
"ip_white_list" from "google_authenticator" configuration key has been replaced by "trusted_ip_list" key. For now, both configuration keys are valid, but only one can be used at same time. "ip_white_list" has been marked as deprecated and will be removed in next major release to keep BC in 4.x branch. Fixes sonata-project#1191
634faa2
to
4e9613e
Compare
All done, thanks for your patience and for teaching me how to improve my Git skills. |
Codecov Report
@@ Coverage Diff @@
## 4.x #1205 +/- ##
======================================
Coverage ? 69.61%
Complexity ? 458
======================================
Files ? 46
Lines ? 1415
Branches ? 0
======================================
Hits ? 985
Misses ? 430
Partials ? 0 Continue to review full report at Codecov.
|
Thanks @davidromani! |
Subject
We should avoid offending terms like blacklist, whitlist, master, slave... and use more tech-related words like blocklist, primary or secondary, for example.
I am targeting 4.x branch because everything is backwards compatible.
Closes #1191
Changelog
To do