-
Notifications
You must be signed in to change notification settings - Fork 2.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
Dynamically update stored credentials in mount config #8167
Dynamically update stored credentials in mount config #8167
Conversation
* @param array $params | ||
*/ | ||
public static function updateDynamicMountPoints($credentials) { | ||
$username = \OC::$session->get('loginname'); |
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'd prefer to use the function getLoginName()
here.
Works and the code looks good but I'm not sure if this is a good approach since it requires the users password to be written to disk (in a non one-way encrypted way) |
Writing the password to disk is no different to how every other external storage works - this just updates it every time the user logs in for dynamic storages. Still not sure if the sharing bug I mentioned is actually a regression from these changes, it would be really handy if someone else could test:
What I saw was a recursive loop of ownCloud refusing to go into the directory. |
Any chance of getting an iRODS test done? |
I'm fairly confident that iRODS will work. I tested a configuration both with 'Use ownCloud login' and without, and as expected the username and password was dynamically adjusted for the 'Use ownCloud login' config while for the one without no such adjustment was made. Ideally someone who uses iRODS needs to test this, but I'm happy that it is working. |
@Xenopathic nice one! I'll test this later. |
@DeepDiver1975 do you have an iRODS env to test this ? |
No - not really - we need to split files_external asap and move iRODS into it's own repo. |
@karlitschek @MTRichards FYI: on iRODS - THX |
Let's also split out the irods into a separate app for now. Then we can see if someone actually needs it and if we ship it. |
I'll take care of this - I'll move that app (let's name it files_irods) into the apps repo. @karlitschek agreed? |
yes. perfect |
@@ -59,8 +51,8 @@ public function __construct($params) { | |||
|
|||
} | |||
|
|||
public static function login( $params ) { | |||
\OC::$session->set('irods-credentials', $params); | |||
public function isDynamic() { |
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 suggest to rename this to what it actually is: useLogonCredentials
which is more explicit and clearer than isDynamic
[minor]
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.
Never mind, I saw that this method is added to the generic Storage interface where we probably don't want to mention logon credentials.
Nice works @Xenopathic ! Please see my comments. |
Wow, everything needs rebasing today 😆 Also, I have no idea how to go about writing a unit test. The only time I tried performing a test the whole thing broke on me, so I've been reluctant to try again. Any tips? |
Instead of storing credentials in a session variable, on login the credentials are used to update any dynamic personal mount points (or create them if system-wide ones are encountered) with the new credentials. Sharing for SMB_OC has been enabled.
@Xenopathic rebase your rebased rebase 😉 For the unit test, have a look here: http://doc.owncloud.org/server/7.0/developer_manual/core/unit-testing.html#running-unit-tests-for-the-owncloud-core-project You can add additional tests in |
PHPUnit tests are in. I tried using |
@Xenopathic I'm not sure why the hook wasn't trigger. |
* | ||
* @return bool | ||
*/ | ||
public function isDynamic() { |
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'm still not convinced about the isDynamic
function. First its name is too generic: what does a "dynamic" storage class mean ? You could rename it to "hasDynamicCredentials".
But still, I think the concept of credentials should not be included in the generic/base class of storages.
I can't think of a better solution right now so I suggest to rename all occurrences of "dynamic" to something more explicit like "hasDynamicConfig()" and "updateDynamicMountPointsConfig()".
@icewind1991 do you have any suggestions ?
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 agree that the wording isDynamic
is to generic, maybe something like useUserCredentails
The unit tests look great! Thanks. |
isDynamic() -> needCredentialsUpdate() updateDynamicMountPoints() -> updateMountPointCredentials() testNonDynamicMountPoint() -> testMountPointNoCredentialsUpdate() testDynamicMountPoint() -> testMountPointCredentialsUpdate()
Hopefully |
The inspection completed: 1 new issues, 7 updated code elements |
The code looks good, thanks. |
🚀 Test Passed. 🚀 |
Also, try this:
It does makes sense technically to auto-generate a personal mount point as this is where the password is saved. But from a UX point of view, if the admin chooses to delete or modify it, it would need to update all the personal mount points. And currently there is no concept of "inherited" mount points. In an ideal world the user should be able to have "inherited mount points" that are read-only and not shown in the personal page, and those would auto-update based on the "root" entry. But that's tricky to implement and I'm not sure whether we want that level of complexity. Needs further discussion. |
Also having an auto-generated personal mount point creates an additional storage entry:
I don't think this is wanted. |
@PVince81 I'll check out that status bug when mounting as personal. I expected the deleting bug to hit. There is currently no way to avoid it, as you say with no concept of inherited or read-only mount points. This also has the disadvantage of requiring I don't think there is any way to avoid getting a redundant storage entry - this is a side effect of autogeneration. |
@PVince81 I had a look at mounting SMB_OC as personal... and couldn't replicate the issues you were having. Both with the branch itself and when merged into master, I got the status correctly shown and the mount point mounted (after a logout and login, of course). |
Is there any point in making a separate |
Not necessarily. Some classes like Dropbox will not use a password but a token. |
Once the |
💣 Test FAILed. 💣 |
💣 Test FAILed. 💣 |
💣 Test FAILed. 💣 |
@Xenopathic in the light of #12216 (the part about capturing credentials) what should we do with this PR ? |
@PVince81 This approach was fundementally flawed from its inception, so I'll close it. Is there any point in keeping the branch available though? |
Instead of storing credentials in a session variable, on login the credentials are used to update any dynamic personal mount points (or create them if system-wide ones are encountered) with the new credentials.
Sharing for
SMB_OC
has been enabled.The following needs testing:
(this is a little broken at the moment)Separate bug affecting SMBThis was a separate issue, fixed in Fix issue with personal mount points and sharing #829321/04/2014 WIP status removed
@PVince81 @icewind1991 @DeepDiver1975