-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Removed chmod from CryptKey and add toggle to disable checking #776
Conversation
If okay, I would like to loosen the permissions to |
I'm happy to merge this if you could please remove the disabling of the check. |
Actually ignore my comment about disabling the check. Instead I'd be happy with an API that looks something like this: $privateKey = new CryptKey('file://path/to/private.key', 'passphrase');
$privateKey->acknowledgeIncorrectKeyPermissions(); // this disables the check With regards to the 600 permission I'm also happy to see |
I would like to, but that might be a bit of a bigger change than possible. The check is done in the constructor. So in order for that code to work the validation of the key needs to be moved. This will change the behavior quite a bit, because checking so will either be done by another class or when one of the public methods is called, changing the place where the error might be triggered (if at all). |
Okay I will re-evaluate the Please can you address the comments I've made on the commit and I will merge this PR. |
which comments? The one about removing the disabling of the check? |
@yannickl88 see my comments in line here https://github.com/thephpleague/oauth2-server/pull/776/files |
I'm not seeing any comments, did you publish them? |
src/CryptKey.php
Outdated
if ($keyPermsCheck) { | ||
// Verify the permissions of the key | ||
$keyPathPerms = decoct(fileperms($keyPath) & 0777); | ||
if (!in_array($keyPathPerms, ['600', '660'], true)) { |
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.
Please change this to use === false
instead of !
src/CryptKey.php
Outdated
*/ | ||
public function __construct($keyPath, $passPhrase = null) | ||
public function __construct($keyPath, $passPhrase = null, $keyPermsCheck = true) |
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.
Please change parameter to $keyPermissionsCheck
src/CryptKey.php
Outdated
E_USER_NOTICE | ||
); | ||
// @codeCoverageIgnoreEnd | ||
if ($keyPermsCheck) { |
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.
Please use the explicit form of if ($keyPermissionsCheck === true)
Apparently not... |
np! should be fixed now. |
So any information on how one would get laravel passport to use this new toggle for the permission check? I just ran a composer update and now my whole dev environment has come crashing down. I am using bash on windows and you cannot chmod files because it ignores it. microsoft/WSL#81 |
There is a third constructor argument for the keys. Setting this to The How to do this with Laravel passport I do not know, we use Symfony. I recommend making a PR there or try to extend it yourself to use this behavior. |
I don't know if this is because I use the built in PHP development server, but my files in windows always report 0666, and folder report 0777. If specific couldn't we have the package automatically disable checking/modification using a php_uname('s') check? |
@cringer bash on windows does not support chmod of files that are stored on the ntfs file system. see microsoft/WSL#81 |
Yeah I get that. My point is that the package is attempting to check and/or modify the permissions on the keys. Since the specified values will always be reported back from a windows system the package will always crash and burn. While a 3rd constructor has been added to disable this check I was just wondering why it doesn't do a check based on the OS anyway. As a cross platform package, it would seem like it would be a better solution to ignore checking and modification completely on Windows. |
@cringer I haven't actually dug into how they are doing the permissions check, maybe it does check the OS but because you are running bash for windows the script execution is happening in a *nix environment. |
@valeryan I don't really think they are checking. If the check was done through PHP it a check to phpuname('s') would return the Operating System of the server running the php. It doesn't matter if the development server was started using command prompt or git bash this will always be Windows. Specifically |
For backwards and crossplatform compatibility $keyPermissionsCheck should be false by default. |
First of all, please do not touch my files... I do not think it's the responsibility of a package to set file permissions. It is the responsibility of your deployment pipeline or developers themselves.
While I appreciate the intent that was done in 2f8de3d. This is breaking for us in both our development and our production environments. And according to #760 for more people.
With this PR I would like to propose two things:
USER_NOTICE
when not set to600
.A bit of context for our case:
Our PROD setup is as follows:
We have 4 users:
deploy
,worker
,scheduler
andapache
. All four are part of thedeployment
group. So our code is chowned asdeploy:deployment
. So while600
might seems like a good assumption, it will prevent ourapache
user from reading the key, thus breaking the web requests.Our DEV setup is a bit different:
We have our own users,
yannickl88
in my case, andwww-data
for the web user. Files are chmodded666
so both users can read everything. (we have a umask 0000 everywhere). While not the best setup, it's just development. In this case660
is even not enough, but a warning would be justified. However, we would like to silence this in our DEV environment since Symfony converts theUSER_NOTICE
to an exception, making the lib unusable.