Skip to content
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

SMB/CIFS mounts using ownCloud login, fixes #7843 #7875

Merged
merged 7 commits into from
Mar 27, 2014
Merged

SMB/CIFS mounts using ownCloud login, fixes #7843 #7875

merged 7 commits into from
Mar 27, 2014

Conversation

RobinMcCorkell
Copy link
Member

This PR provides a new mount type, that uses the user's ownCloud login credentials to connect to the SMB/CIFS share. It also has the ability to use the username as the share name, for use with home shares. The username and password are stored as session variables, however I do not consider this a security risk as iRODS already does the same thing.

Fixes #7843

Please review @blizzz @PVince81 @icewind1991 @DeepDiver1975

@icewind1991
Copy link
Contributor

The admin interface shows the external storage to be invalid since it wont be able to check if the storage is valid without login in to cache the credentials, this check will need to be overwritten.

Besides that everything seems to work

@RobinMcCorkell
Copy link
Member Author

Hmm, how should that be implemented? I could override the check to always return success, but perhaps extending the current status mechanism to include a yellow 'unknown' symbol might be the best solution?

@icewind1991
Copy link
Contributor

Maybe only check if the hostname provided is valid

@ghost
Copy link

ghost commented Mar 25, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/3873/

@PVince81
Copy link
Contributor

Another "problem" here is that the password is always stored in the session regardless whether any ext storage is used. You only need to enable the app and then the password will be stored.
I'm not sure how to do this better, it might be possible to find out whether at least one SMB_OC storage is mounted, and only then the password would be stored.

I know you copied this from iROdS, I never realized that it worked that way... (CC @LukasReschke)

@RobinMcCorkell
Copy link
Member Author

Is that an issue? All communication between a client and the server is over HTTPS, and we assume the browser is secure, so there is little to no security risk with this surely?

@LukasReschke
Copy link
Member

Storing the password in the sessions which may get stored on the local file system is a bad idea.

This basically makes ownCloud "one service to pwn them all" (especially in LDAP environments), if an attacker gains access to the sessions he has access to the clear text passwords of every user... This is not really what a normal user or sysadmin would expect.

I do understand the need for such "SSO" setups. And I think that there is not a secure solution at all. Therefore I'd like to suggest one of the following two approaches:

  1. The password is stored in the session but encrypted with the salt in config/config.php
  2. The password is stored encrypted inside the users mount config and updated after every login.

I think 2 may be a better approach as it allows ownCloud to access the mountpoint even if the user is not logged in (e.g. for some occ commands)

In both cases when clicking the "use the same login" checkbox a warning should get shown to the user/admin explaining that this requires ownCloud to store the password in plaintext and in case of a security vulnerability an attacker may be able to gain access to the ownCloud password.

Any other suggestions?

@LukasReschke
Copy link
Member

And as Vincent said: The password should only get stored if a mountpoint requires it.

@PVince81
Copy link
Contributor

Question is, should this be fixed separately ? Because that's what happens for iRODS.
We could fix this for iRODS first then reuse it for this PR ?

@LukasReschke
Copy link
Member

Yeah. This would be a good idea.

@RobinMcCorkell
Copy link
Member Author

Caching the password in the mounts config could also provide a partial solution to the sharing problem.

@PVince81
Copy link
Contributor

One idea would be to modify the login hook and make it go through the "Config" class. That class could then check whether there is a mount for SMB_OC or iRODS and then store the password into its config (if it has the "use ownCloud login" flag set).

@PVince81
Copy link
Contributor

Ok maybe not iRODS yet as it might not work, we can do that later separately.

@RobinMcCorkell
Copy link
Member Author

Well that's the checks part complete. Tested here, seems to work, please review.

An interesting bug I found: when configuring a system share with 'All Users' defined, the check performed is done with $isPersonal = false (aka a system share), which is correct. However, reloading the page, or indeed loading that page with already configured shares that use 'All Users', the check performed is done with $isPersonal = true, which knocks out my custom logic and is likely not desired behaviour.

EDIT: Ignore me, that seems to be a bug of my modified code.

@ghost
Copy link

ghost commented Mar 26, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/3895/

@ghost
Copy link

ghost commented Mar 26, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/3896/

@PVince81
Copy link
Contributor

@Xenopathic you might not need the option "username as share", there is an obscure hidden feature in the code where "$user" gets replaced by the current user, see owncloud-archive/documentation#307

But keeping it is good for visibility / UX

@PVince81
Copy link
Contributor

Going to test this:

  • Old SMB still works (regression test)
  • System-wide SMB_OC with "username as share"
  • System-wide SMB_OC with custom share name
  • Personal SMB_OC with "username as share"
  • Personal SMB_OC with custom share name

@PVince81
Copy link
Contributor

One test failed. Note that I've used a "root" value for all shares.
Might need to retest everything without "root" value

TODO:

  • raise separate issue/PR for the password storage

@PVince81
Copy link
Contributor

  • retest the steps above with an empty root (I believe the code path is slightly different)

@RobinMcCorkell
Copy link
Member Author

The system wide tests without root work fine for me. I will see what is wrong with a non-empty root, and a custom share name.

RE the separate PR for password storage - should it reference the iRODS credential mechanism, or wait until this PR goes through so that it can reference both?

@PVince81
Copy link
Contributor

As you like.
I do hope to get your PR merged soon anyway 😉

@RobinMcCorkell
Copy link
Member Author

Hmm, custom share name with root is working fine here.

@PVince81
Copy link
Contributor

Oh noes, it seems you need to rebase onto master.

I tried again from scratch and I still don't see the "/smb" mount point appearing in the file list.
These are my settings:
smboc

@PVince81
Copy link
Contributor

Wait... I think I see. Of course the user "root" doesn't have smb access. Trying with the correct user now.

@PVince81
Copy link
Contributor

Never mind, it works. It was just a misunderstanding.
I logged in with a user that has the same uid and password on the Samba server and it worked.

@PVince81
Copy link
Contributor

Please rebase this and then I think it's good to go 👍

@icewind1991 second review?

Selecting 'SMB/CIFS Auto' in the mounts configuration allows an SMB/CIFS
mount to be configured that uses the credentials of the user logging in to
authenticate to the server.

Optionally, the username can be used as the share name, permitting home shares
to be dynamically mounted.
Robin McCorkell added 5 commits March 26, 2014 14:35
getDisplayName would return the display name of the user, not great if it is a
canonical string. The uid passed back from 'login' is the UUID of the user, so
also not suitable. The login name from the session is the username the user
used to log in to ownCloud in the first place, which is what is needed.
Shares authenticated with user credentials (aka not hard coded) cannot be
accessed by other users, breaking sharing. This change completely revokes
sharing for such shares
SMB_Auto is now SMB_OC, and the name has been changed from
"SMB / CIFS Auto" to "SMB / CIFS using OC login"
To check for shares, the code attempts to connect anonymously to the share.
In most cases this will fail with NT_STATUS_ACCESS_DENIED, so the regex array
used for parsing the output of smbclient in smb4php has been overridden to
treat such output as success.

The 'test' method for storage classes can now take a single parameter,
$isPersonal, which allows the storage to adjust the tests performed based on
if they are being configured as personal shares or as system shares.
@RobinMcCorkell
Copy link
Member Author

Rebase complete


public function test($isPersonal = true) {
if ($isPersonal) {
if ($this->stat(''))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use {}

@icewind1991
Copy link
Contributor

It still shows the mount as invalid in the admin panel for me

@scrutinizer-notifier
Copy link

A new inspection was created.

@RobinMcCorkell
Copy link
Member Author

@icewind1991 Can you post the details of the configuration? And if you try to run:

smbclient -N //<host>/<share -c 'exit'

What error do you get? You should get an NT_STATUS_ACCESS_DENIED, which is correctly detected by the code as success.

@ghost
Copy link

ghost commented Mar 26, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/3903/

@ghost
Copy link

ghost commented Mar 26, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/3904/

@PVince81
Copy link
Contributor

@icewind1991 did you pull ? What combination of settings did you use ?

@icewind1991
Copy link
Contributor

Never mind, the problem was that I didn't do a login after checking out the branch, works for me now after a re-login.

👍

PVince81 pushed a commit that referenced this pull request Mar 27, 2014
SMB/CIFS mounts using ownCloud login, fixes #7843
@PVince81 PVince81 merged commit 1f6259d into owncloud:master Mar 27, 2014
@PVince81
Copy link
Contributor

@Xenopathic do you want to take care of the "only store password when mount point is used" part as a separate PR ? (with the details I suggested here #7875 (comment))

Edit: missing word

@RobinMcCorkell RobinMcCorkell deleted the files_external_smb_auto branch March 27, 2014 14:24
@RobinMcCorkell
Copy link
Member Author

@PVince81 Sure, I'll get on it.

@PVince81
Copy link
Contributor

Excellent. Thanks a lot for your contributions 😄

@segdy
Copy link

segdy commented May 2, 2014

Hi, did this patch find its way in the official branch? When would it be available in the official version?

@LukasReschke
Copy link
Member

It will be included in our next major release: ownCloud 7.

@segdy
Copy link

segdy commented May 2, 2014

Thanks! Cool, can't wait for it ... will retry my experiments then.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SMB/CIFS mounts using logon credentials
6 participants