Needs work
Project:
Drupal core
Version:
main
Component:
user system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 May 2008 at 22:40 UTC
Updated:
12 May 2020 at 08:51 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mdupontBumping to 8.x.
Comment #2
mdupontQuick patch attached allowing a configurable TTL for one-time login links. Configurable through admin/config/people/accounts. Restricted length to 10 digits, which already allows for a maximum TTL of more than 317 years... should be enough ^^
Comment #3
mdupontTagging Novice.
Comment #4
danielb commentedJust thinking out loud, but the size of integers is platform dependent, perhaps consider using PHP_INT_SIZE.
Comment #5
rickmanelius commentedInteresting. Will attempt as part of my 30 min of drupal community time tomorrow :)
Comment #6
rickmanelius commentedAlso thinking out loud. Would it be a security risk to not have any time limit at all? (e.g. 0 for unlimited?)
Comment #7
rickmanelius commentedI can confirm that the patch works as directed.
I suggest we either add in the max php size and possibly an unlimited option now or open as another ticket. Thoughts?
Comment #8
mdupontSome thoughts:
- limiting size to 8 numbers will already allow for a maximum timeout of more than 3 years and will always fit in an integer on 32 bits platforms
- which value is generally used throughout Drupal to mean "unlimited"? Is it 0 or is it a negative number (-1)? Currently there is no enforcement that only a positive value should be entered.
Comment #9
danielb commentedTypically 0 is used for 'unlimited' in Drupal in situations where a literal value of zero would be useless.
And 8 is probably a better limit. I don't know of any systems that support a max of fewer than 8 digits in an integer?
Comment #10
rickmanelius commentedI agree with #9. I knew in views, for example, 0 is often used to denote no limit.
A size of 8 seems fine. Anyone wanting longer is likely to just use 0 and be done with it.
Comment #11
mkadin commentedHere's a patch that is re-rolled for D8 and has shortened the length of the number of seconds to 8 digits.
I don't love that the time has to be entered in seconds...not a great way for newbies / non-technical folks to have to enter this. Could we use php's function that converts strings to time? Or maybe a select form element with 1-7 days instead?
Comment #12
kristen polComment #13
kristen polWhat about either:
1) Making pre-configured settings, e.g.
1 day
2 days
1 week
2 weeks
4 weeks
like what is done on the
admin/config/development/performancepage forMinimum cache lifetimeandExpiration of cached pages.or
2) Have the settings so they choose the number of days and hours, e.g.
2 days and 3 hours
and then it is converted to seconds.
Comment #14
mkadin commentedI like the drop down idea. Patch attached.
Comment #15
kristen polI applied the patch and confirmed that, after choosing a particular duration, the correct value was in the variable table in the database. In particular:
1 day = 86400
2 days = 172800
1 week = 604800
2 weeks = 1209600
Beyond that, I'm not sure what else can be easily tested.
Comment #16
Cauliflower commentedThe patch in #14 works but contains some unnecessary spaces and rules. The patch could also be simplified because the timeout already uses a variable.
I made a new patch that fixes the remarks above.
Comment #17
kristen polThe patch code looks good, but I haven't tested it and am pressed for time... hope someone else can try out soon.
Comment #18
Bußmeyer commentedapplied the patch and works well for me.
Perhaps it might be a good idea to add more alternatives as items in the drop down?
Comment #19
Cauliflower commentedThx both for reviewing!
I added a few more options:
Is that long enough you think ?
Comment #20
Cauliflower commentedSorry, patch in #19 contained some other changes as well. The patch attached to this comment is the right one.
Comment #22
Cauliflower commented#20: 263932-20-user_settings_to_set_reset_timeout.patch queued for re-testing.
Comment #23
derEremit commentedpost feature freeze for 8.x
forwarding to 9.x
Comment #24
catchI'd put this into 8.0.x without a UI - having this hardcoded seems like an omission given the issue summary.
We could add a UI in 8.1.x.
Comment #25
Josh Benner commentedIt seems this was essentially already done during some other refactoring. See user.settings.password_reset_timeout.
Comment #26
Josh Benner commentedActually, keeping open to add UI after 8.0.0
Comment #27
koolaidguy commentedAdding this to D8
Comment #28
koolaidguy commentedAdding the configurable timeout to D8
Comment #30
koolaidguy commentedResubmitting patch after pull
Ignore this patch, a better patch is on the way.
Comment #31
koolaidguy commentedNew patch that allows default setting for timeout to be preserved.
Comment #32
koolaidguy commentedComment #34
koolaidguy commentedOne more try to get this patch to work
Comment #35
koolaidguy commentedRe-rolled this patch, it seems to work fine on a brand new checkout.
Comment #37
koolaidguy commentedI know this is getting crazy, there was a tab in the patch.
Comment #39
sumitmadan commentedRerolled the patch.
Comment #41
mikgreen commentedRerolling.
Comment #45
sumitmadan commentedRerolled with the latest code.
Comment #47
sumitmadan commentedComment #50
deepakaryan1988Removing sprint weekend tag!!
As suggested by @YesCT
Comment #51
deepakaryan1988Sorry, these issues were actually worked on during the 2015 Global Sprint
Weekend https://groups.drupal.org/node/447258
Comment #52
lammensj commentedFixed the error: the config used in the controller and in the form (password_reset_timeout_override) was not configured in the schema.yml. Hence the failing tests.
Comment #53
cyberschorschI am going to review this issue
Comment #54
cyberschorschThank you for fixing this problem.
I reviewed it manually and I think this needed more work. It is possible to enter anything in this field and this is not how we should do it. Instead, I changed the type of the field to "number" and added a "min"-Value to the field.
Comment #55
McGo commentedI successfully reviewed the patch from #54 and it applies and works as expected. A better UI really is needed in 8.1.x presenting a drop down menu with predefined values.
Comment #56
McGo commentedTest passed, so i set it to RTBC
Comment #57
lammensj commentedI replaced the input field with a select list, with options as proposed in #15. I thought that this wasn't worth waiting for the 8.1 version, it was an easy edit.
Comment #58
cyberschorschHmm, I don't like this completely. I already talked with McGo about this and I think we should add another option "custom" in the select list which triggers a new field which lets you add an individual intervall in seconds.
Comment #59
lammensj commentedAren't we overthinking this? I mean, it's the expiration time of the one-time-login link. I can't even remember if a client ever asked me if it could be changed...
For cache invalidation I can understand why someone would need the custom choice, but not for this...
Comment #60
andypostthis is a feature
Comment #61
mariano.barcia commentedThe KISS principle is a good guide, let me ask the following questions:
a) what would be the use case for such additional "custom" field displaying on and off?
b) is that case popular enough to be in Drupal?
c) if yes, does it need to be in core?
Regarding the patch, I don't quite understand the need of the additional variable "password_reset_timeout_override". I'll try to achieve the same without it.
Comment #62
mariano.barcia commentedNew (simpler) patch, achieved same functionality without the additional variable.
Comment #64
mariano.barcia commentedPatch re-rolled without CR line endings (doh!).
Comment #65
joshi.rohit100Well what if I want my link to be expired on 3 days, 4 days, 3 weeks etc. ? So I guess I am not achieving this by select list.
So shouldn't this be a text field contains timestamp. This will give more flexibility.
thoughts ?
Comment #66
mariano.barcia commentedWell, the same argument would apply to the page cache max-age, and the options there are fixed and do not allow any 'custom' value. This is for simplicity, as specific values of ie. 3524 seconds would be no different than 3600 from a business user's perspective.
IMHO, this improved scale should be enough:
1 day
2 day
3 days
5 days
7 days
14 days
30 days
Comment #67
mariano.barcia commentedComment #68
fractile81 commentedHowdy, all!
I originally created this issue and it was for an explicit use case: in our organization we had support staff that would send password reset emails for customers when they called in for assistance. Organization policy was to allow an individual 1 week to take action on a correspondence (e.g., they were away for vacation or a weekend and had no email). Given the possible lag-time in receiving an email, it made sense for the industry we focused on.
My two cents: I think a UI similar to the cache dropdown with pre-selected values is suitable. If it's a real concern, someone can manually set a value using a custom configuration (YAML, settings.php, etc.).
For the option names, I'd go with what's in #66 and change:
- 2 day => 2 days
- 7 days => 1 week
- 14 days => 2 weeks
- 30 days => 1 month (and have the value represent 28 days)
We should just KISS and mimic the cache dropdown: it maintains UX/DX consistency.
Comment #69
5hawn commentedWorks for me. Applied the patch on both simplytest.me and my local environment.
Comment #71
mariano.barcia commented(My last patch had passed, now it is failing? Seems like a new test in Migrate isn't doing very well?)
Ok, works for me too. There's one more thing that I find... disturbing in the force...
There is a mismatch between the options units, and the real value unit. The real value stored in the configuration is measured in seconds, while the options are in whatever days, weeks or months. So, what if someone provides a value of of 3456 seconds through a YAML configuration? When he loads this admin screen: which value will be shown set? Suppose is shows [the closest option to that value] set, but then, if you save, you will have changed the configuration without knowing.
The max-age code for page cache has to deal with this as well... would like to see how it's done.
Comment #72
fractile81 commentedThe page cache code doesn't do any special handling (at least in D7). If it's a large concern, the field type can be changed if the number of seconds don't match any that are supported, otherwise keep a select. I would think manually setting the value would be an edge case, though.
To help avoid this edge case even further, I wonder if we should include hours as options? This would allow for tighter security on the emailed login token. This is the opposite of my original use case, but I can see it being useful.
3600 - 1 hour
7200 - 2 hours
14400 - 4 hours
28800 - 8 hours
43200 - 12 hours
Comment #73
markdorisonComment #74
markdorisonTrying again with the correct patch file.
Comment #76
mariano.barcia commentedI think we should check the timeout value before filling it in and, if it does NOT match any of the pre-set options, alert the user so she doesn't change it inadvertently. If someone decides to "inject" her own value here, we should allow for it, but also cover the case where the user actually wants to revert that to one of the pre-set options. So the pre-set options only need to be "good enough" for most users, which I think they already are.
We are limiting the TTL for added security (that's why we're not including "forever" in the options) and scaling down to "hours" seems too tight, just my opinion.
Comment #77
markdorisonThe case we are discussing here is not unique to this issue. I took a look at how core handles the max-age settings on the 'performance' configuration form. If a the stored setting matches one of the options, it selects it as the default. If the stored setting does not match any of the available options, it defaults to showing the first option in the list, which in this example is 'no caching'. I can see merit in improving the UX of how this is handled, but I might argue that it shouldn't be a blocker for this and could live in it's own issue.
I would respectfully disagree with you there. I could easily imagine short settings being quite useful.
Comment #78
mariano.barcia commented@marcdorison thank you for finding that code. I may add that the behavior you've described is not enforced, but a side-effect of the config value not being found in the preset options and defaulting to _some_ value, probably the first element. And the first element (no caching) is not really the safest option is it?
In that code, and in this patch we're working on, I believe the user should be alerted somehow, and I agree it could be handled in separate issues, so as to unblock this one.
It makes little to no technical difference, but I'm just curious, could you describe one use case? Thank you in advance.
Comment #79
fractile81 commentedDrupal sites have a vast range of security and accessibility needs. We're only trying to remove a hard-coded 1-day TTL and provide a form field with a range of options that should suit most sites. Options under and over a day, at the aforementioned intervals, should fulfill this goal.
The hourly use cases benefit sites that want tighter security with little moderation. I can imagine a commerce site wanting to reduce the amount of time a "log in for free!" token stays alive. If a user is actively trying to reset their password, and assuming the internet is working at an adequate speed, the span of a whole day to reset their password seems excessive when some form of MITM attack could be executed on the email and compromise an account that has purchasing power. Another case could be for a public-facing "intranet" site: internal emails should route quickly, so having the TTL set so long shouldn't be needed. Simply adding these hourly options is an easy way to give site builders a choice in how to further manage their security.
Comment #80
mariano.barcia commentedAlright, so in this new patch attached, I've:
Hope you find it useful, please test, thank you all.
Comment #81
markdorisonPatch tested fine.
$timeout_scalearray declaration: "If the line declaring an array spans longer than 80 characters, each element should be broken into its own line."#descriptiontext.Comment #82
adamzimmermann commentedGrammatically this should use "one day" instead of "1 day". However, "1 day" matches the output of dateFormatter, so perhaps we leave it as is?
Other than that, the code looks good and seems to be working in my basic testing.
Comment #83
mariano.barcia commentedYeah "1 day" is good as it matches the value option. Also, note that "one day" may also mean "one day..." like in ie. www . peaceoneday . org
As 3 of us have tested the last patch with success, I'm marking this one as reviewed.
Comment #84
alexpottIt's already configurable - just not through the UI.
Comment #85
alexpottWe should at least test that the configuration is successfully saved by the form.
Comment #86
alexpottThis looks unnecessary. The default value could only be empty if the user has hacked config. I would just do:
'#default_value' => $config->get('password_reset_timeout'),Comment #87
mayurjadhav commentedHi,
@alexpott make sense, we can directly add
I manually tested it and the configuration is successfully saved by the form.
Uploading patch with making #86 changes.
Thanks.
Comment #88
alexpottstill need an automated test. Maybe add a new test method to UserAdminTest
Comment #89
markdorisonComment #90
cyberschorschI added a test which sets the TTL to 1 hour and saves the form. Afterwards, it checks the config for the stored TTL.
Comment #92
zserno commentedGreat effort, @Cyberschorsch. I found the following minor issues:
As per #82 this should say "one day".
Typo at the end of the sentence: "...1hour.s"
Comment #93
markdorisonFixed issues detailed in #82 & #92.
Comment #94
cyberschorschA, I see you uploaded the wrong patch. Let me change that real quick
Comment #95
cyberschorschFixed the typos.
Comment #96
markdorisonI believe a semi-colon here makes more sense than a comma, but I am fine with it either way.
However, '1 hours' should be the singular '1 hour'.
Comment #97
cyberschorschOkay, changed it.
Comment #98
duaelfrGood work here!
Reviewing the code I only have two tidbits:
[Documentation] The docblock of this method must be updated by mentioning the new parameter.
[DX] Could we have some comments on each line to show the human readable value?
ie. 3600, // 1 hour
604800, // 7 days
Comment #99
cyberschorschGood catch, DualFR!
I updated the documentation, also rebased again.
Comment #100
dawehnerAs said it would be nice to remove the description as there is really no value in it. It says the exactly same as the title.
Comment #101
markdorisonThe changes in this patch do not conform to Drupal coding standards:
The comments added per #98 do not pass PHPCS.
Comment #102
Pradnya Pingat commentedComment #103
Pradnya Pingat commentedI am trying to apply patch but its not getting apply .So changing status from needs work to needs reroll.
Comment #104
Pradnya Pingat commentedComment #105
Pradnya Pingat commentedby mistakenly marked as resolved
Comment #106
Pradnya Pingat commentedComment #107
markdorison@Pradnya The latest patch applies cleanly against HEAD of 8.2.x. Are you trying to apply against that branch?
Comment #108
Pradnya Pingat commented@markdorison Yes ,let me try Once again and get back to you.
Comment #109
Pradnya Pingat commented@markdorison Sorry my bad .patch applies cleanly. Making changes as per coding standards.
Comment #110
cyberschorschWhy is your patch this large? It seems like you changed the intendation?
I think we should focus on the actual issue here. When we fix the comments, I think this issue is done..
Comment #111
ashishdalvi@Pradnya Pingat : Patch submitted by you seems to be incorrect patch. Please verify your submitted patch.
Comment #112
Pradnya Pingat commentedmistakenly uploaded file .Adding new patch file with coding standard fixes as per comment #101
Comment #113
cyberschorschThe "hours" wording error was still present, corrected that.
Comment #114
cyberschorschComment #115
duaelfrThank you all for your work here! You're on the right way!
Here are a few more things, though.
To pass PHPCS validation the comments have to be on the line before the statement. eg:
Some other points from #101 haven't been fixed yet.
Comment #116
mayurjadhav commentedUpdated the patch with suggested changes in #101 and #115.
Comment #118
quietone commentedWhat an interesting find. It would be handy to have this functionality.
I read through the issue and the only thing I found not addressed was dawehner's comment in #100 about removing the description.
Line > 80 characters. And is there a reason the data formatter wasn't added at the end of the list of returned items?
Capitalize the acronym, TTL.
Shouldn't TTL be stated in full before the abbreviation? As in 'Test saving the time to live (TTL) for ...'
Comment #123
izus commentedpure reroll of #116
Comment #124
izus commentedhi,
here is a patch that adresses #118
Thanks
Comment #125
interx commentedThanks, this patch comes in handy. It makes the contrib solution User Password Reset Link Timeout no longer necessary to simply adjust a core variable.
I tested the patch and it works for me.
Some remarks on the patch:
Why move the services onto one line instead of keeping them on multiple lines?
This needs to use the short array syntax.
Single quotes should be used by default.
Comment #126
interx commentedComment #127
andypostUse $this->t()
Comment #128
izus commentedHi,
Thanks for reviews
here is a patch that adresses #125 and #127
Thanks
Comment #129
interx commentedHere's a patch that fixes the minor coding standards
Comment #130
interx commented@izus you beat me to it, almost submitted a patch simultaniously :)
I moved the DateFormatter service to the end of the list for classes that already extend AccountSettingsForm. Seems to make more sense to not inject new services in the middle of others.
Comment #131
jollysolutionsComment #132
jollysolutions#129 Tested and works for me
Comment #133
larowlanthis needs to use short array syntax
Thanks for working on this
Comment #134
hardikpandya commentedComment #135
izus commentedHi,
#134 Tested and works for me
the two modifications adviced in #133 were adressed by #134
so back to RTBTC
Thanks
Comment #137
zuhair_akRerun the test bots again
Comment #138
jollysolutions#137 works for me
Comment #140
zuhair_akRunning the testbots again
Comment #141
andypostBack to rtbc
Comment #143
zuhair_akRetests are passed. We will set it again to RTBC and see what bot says.
Comment #144
catchTagging for usability review.
Comment #145
gábor hojtsyWhat's the use case for week and two weeks? The issue summary explains business users and weekends as use case for 2 days, but weeks came up later. They could still ask for another login link. I recently got beaten multiple times by Google's login tokens expiring in a few hours, but these limits are in the interest of security.
Comment #147
Anonymous (not verified) commentedComment #149
kenton.r commentedI am using the 263932-140.patch and I use it at 2 weeks. My use case is that I import user accounts and send the links which have an average of click time of one week for the individuals to follow through with the registration process. They are not the ones who initiate the email so there needs to be time for them to find time in their schedule to finish the registration.
Comment #152
quietone commentedI skimmed through the issue and it isn't clear what the next step is, but it certainly isn't novice anymore. Also needs IS update. And note that this has security factor to consider, as mention in #145.
And the patch needs a reroll.
Comment #153
sja112 commentedPatch re-rolled.
Comment #155
sja112 commentedUploaded incorrect patch in #153.