core icon indicating copy to clipboard operation
core copied to clipboard

[5.0.11RC1] Share link -- expiration date was set to past date -- link still valid

Open ser72 opened this issue 13 years ago • 28 comments

Expected behavior Link is expired

Actual behavior Link is accessible. ownCloud shows the file as “Shared”. Under shared tab, ownCloud seems to be unshared.

Steps to reproduce

  1. Share a file via a link
  2. Set an expiration date – by accident (on purpose) set it to an already expired date as below (current date is 8/29/13).

share_1

  1. In another browser (simulating a different user), go to the link. Notice it is available even though it should be expired:

share_2

Files can be viewed and downloaded. 4. Go back to ownCloud web page. Top level on files shows it is shared. However, when you select “share” there are no users listed and the “Share as Link” is not checked:

share_3

  1. At this point, go back to the link and it has expired.

SUGGESTIONS:

  1. Gray out all dates prior to the current date so a user cannot accidently select a previous date
  2. Make sure the link is expired if the expiration date is passed

{"installed":"true","version":"5.0.15","versionstring":"5.0.11RC1"} Ubuntu apache Internet Explorer 9, Google Chrome, Mozilla firefox

ser72 avatar Aug 29 '13 17:08 ser72

It could be that shares are only deleted via cron.php. Access cron.php first and try it then again.

shoeper avatar Aug 29 '13 17:08 shoeper

@bantu free resources left on your side to take a look? THX @karlitschek who else could have a look?

DeepDiver1975 avatar Aug 29 '13 20:08 DeepDiver1975

@schiesbn

karlitschek avatar Aug 30 '13 10:08 karlitschek

Can take a look tomorrow. Feel free to assign to me.

bantu avatar Aug 30 '13 16:08 bantu

This is at least partially an issue with UI, namely the lack of feedback (whether the operation has succeeded or not). @owncloud/designers

bantu avatar Sep 01 '13 11:09 bantu

@shoeper Clearing expired shares via cron probably makes sense, but not checking the expiration date when a file is accessed does not. So I think/hope/expect expires are not only handled by cron.

bantu avatar Sep 01 '13 11:09 bantu

@shoeper Actually, on closer inspection, you may be entirely correct. Taking a deeper look.

bantu avatar Sep 01 '13 11:09 bantu

Another issue related to this report: OCP\Share::getShareByToken($token); returns share data for expired shares. I think it shouldn't. What do you think? @karlitschek @DeepDiver1975

bantu avatar Sep 01 '13 17:09 bantu

To summarise, at least three things need to be addressed here:

  1. An expired share should not be accessible regardless of (cron) garbage collection.
  2. When setting an expiration date that is in the past and the file is no longer shared with anyone, the "Shared" icon should be gone.
  3. Lack of feedback for all non-first share operations (e.g. adding an expiration date or password to an existing share). (The "Shared" appears after the initial share, so there is some feedback for the first operation.)

bantu avatar Sep 01 '13 17:09 bantu

Also cc @schiesbn

bantu avatar Sep 02 '13 08:09 bantu

I didn't had a look at the code. But a general idea:

I would suggest to check the expire date every time a share gets accesses (e.g. someone opens a public link, someone opens his /Shared folder and we collect the file list, someone opens a random folder and we check the share status to display the icons). If the share is expired we remove it from the database and doesn't return the content, doesn't include it in the files-list for the accessed Shared folder or doesn't add the share icon. This way we make sure that nobody will be able to access a expired share, the icons will be always up-to-date and that the database will be cleaned-up in a adequate time frame without the need of a cron.

Regarding the date-picker, it would be nice to grey out dates in the past. But afaik we use a third-party date-picker so I'm not sure if this can be done easily. If we just silently remove the share if the user chooses a expire date in the past this could be quite irritating, because the user maybe doesn't even know that he had choose a date in the past by accident.

schiessle avatar Sep 02 '13 11:09 schiessle

For me that doesn't make any sense. Think of a company using owncloud. 100 people using the cloud all day. At the moment the shares are checked as often as the cronjob runs. Then every share in a certain folder will be checked every time the page is accessed. That will slow down the whole server and leads to millions of useless sql queries. I think it should just be added that a share won't be accessible after the expire date. Performance should always beeing kept in mind.

In case of the date picker I agree with you.

shoeper avatar Sep 02 '13 13:09 shoeper

100 people using the cloud all day. At the moment the shares are checked as often as the cronjob runs.

I don't understand it. Afaik the current implementation doesn't use cronjobs to check any shares.

I think it should just be added that a share won't be accessible after the expire date. Performance should always beeing kept in mind.

This check is exactly what I suggest. All the operations I mention above already perform a db query. To check if we need to set the "shared"-icon we need to query the db, to list the /Shared folder we need to query the db to get the correct file-list and to display a public share we also query the db to verify the token.

All this query can already return the timestamp in the result array without any additional queries. The only think which we would add is a a comparison of two integers to see if the share is still accessible or not. If not we delete the share from the db to clean-up the database. I don't see a performance issue here.

schiessle avatar Sep 02 '13 13:09 schiessle

Yes, ok I'm sorry. I just forgot that the shared icon is still permanently displayed when the file is being shared.

shoeper avatar Sep 02 '13 13:09 shoeper

Expiration seems to solely happen in the (380 lines) method getItems() (see https://github.com/owncloud/core/blob/master/lib/public/share.php#L828). If an expired item is accessed, the table entry is deleted and execution continues without the affected entry (see https://github.com/owncloud/core/blob/master/lib/public/share.php#L1092).

The getItems() method is however never used when files are downloaded when a token is involved (i.e. when share is of type SHARE_TYPE_LINK). The method getShareByToken() is used which does not check expiration (see https://github.com/owncloud/core/blob/master/apps/files_sharing/public.php#L22 and https://github.com/owncloud/core/blob/master/lib/public/share.php#L285).

bantu avatar Sep 04 '13 12:09 bantu

@bantu This is fixed for me in master. I didn't read the whole conversation. Please reopen if this is still an issue.

MorrisJobke avatar Oct 07 '13 12:10 MorrisJobke

@kabum Please stop closing tickets that are assigned to me. I very much doubt all three points of https://github.com/owncloud/core/issues/4649#issuecomment-23629193 have been addressed and I am not going to verify whether that is the case or not right now.

bantu avatar Oct 07 '13 12:10 bantu

@bantu Sorry...thought that this is an forgotten issue.

MorrisJobke avatar Oct 07 '13 12:10 MorrisJobke

Any update on this ?

PVince81 avatar Feb 07 '14 17:02 PVince81

@bantu any update on this ?

PVince81 avatar Jul 24 '14 15:07 PVince81