-
Notifications
You must be signed in to change notification settings - Fork 864
Confirm Email Token Expiration/Lifetime #859
Comments
Alternatively you can set them to be different token providers via https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity/TokenOptions.cs |
That's what I ended up doing, but in order to have a different value for the injected Here's what I ended up doing; is this what you were referring to or is there actually a simpler way?
|
Ah yeah you can't have different options for the same class no, see related #465 |
Thanks guys for the work around. Just wanted to add a scenario and a voice here. An internal employee added a user to our site on Friday and triggering an activation email for the new user. New user didn't click the activation link until Monday. Token expired. It would be ideal to have an easy options configuration similar to how AddIdentity is done. |
Indeed and that’s a pretty similar scenario to what we’ve run into. We have a system set up where administrators can “invite” new users to the site, which basically generates a confirm email token (technically I’m using a different In addition, I think it would be great if the documentation / new project template said something about this. The new project template’s In this case, with the default boilerplate code, they will (hopefully) contact support, but even then the site owner/administrator can only apologize, delete the half-set-up account, and say “try again”. An ugly user experience at best. (I suppose the other option is to manually set the user’s email-confirmed flag, then direct them to the “forgot password” form – but this is not security-ideal unless we make sure to manually confirm the email loop.) To avoid this we need a way to re-send out a token after it’s expired. Perhaps ideally this would be in response to “invalid token” when the user clicks an expired link. (Because we were getting so many support calls about this one I’ve gone a different route and created an admin controller action that accepts an email address, so we can re-send emails with tokens directly.) Either way having at least a note in the documentation that this might be necessary would bring this to light earlier. Ultimately this is all one man’s opinion, but I just wanted to get it on record. If I had more time I’d offer to write something up, but unfortunately I’m not at that stage yet. From: Ro3A [mailto:[email protected]] Thanks guys for the work around here. Just wanted to add a scenario and a voice here. An internal employee added a user to our site on Friday and triggering an activation email for the new user. New user didn't click the activation link until Monday. Token expired. It would be ideal to have an easy options configuration similar to how AddIdentity is done. — |
See also #465 |
Short term plan is to add TokenProviderInstance to the TypeDescriber map, so an instance can be jammed in via IdentiyOptions configuration |
Any news on all this? Has it all been done so i can change the tokenLifeTime for just the EmailConfirmation token?? |
Yes do you have example code on how to do this? How do you change the message from simply "Invalid Token" ? |
You should be able to plug in your own instance of a token provider like this: https://github.com/aspnet/Identity/pull/983/files#diff-1f767f1c742b161c6a1650ec072addeeR645 |
@HaoK Could you please give code sample on how to change the My understanding when looking at https://github.com/aspnet/Identity/pull/983/files#diff-1f767f1c742b161c6a1650ec072addeeR645 , I need to create an instance of Am I on the right track? Currently, I am still using @lcalabrese 's implementation. |
Also looking for a code sample to change the |
Yup @jrgunawan that change allows you to specify a instance with the appropriate token life span |
Any chance someone has code sample to show this? |
Just follow the posted answer by @lcalabrese. It changes the default |
For me I had to add an a little bit more info when adding the identity in order to force the new token provider on password create and update. services.AddIdentity<ApplicationUser, IdentityRole>(
options =>
{
options.Tokens.PasswordResetTokenProvider = EmailConfirmationTokenProviderName;
options.Tokens.EmailConfirmationTokenProvider = EmailConfirmationTokenProviderName;
})
.AddEntityFrameworkStores<PortalDbContext>()
.AddDefaultTokenProviders()
.AddTokenProvider<ConfirmEmailDataProtectorTokenProvider<ApplicationUser>>(EmailConfirmationTokenProviderName); |
thanks !
|
The previous cited url of "https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity/TokenOptions.cs" is broken (404). |
Currently the different types of token (Confirm Email/Password Reset/Change Email) use the same shared
DataProtectorTokenProvider
named "Default" which in turn all share the sameDataProtectionTokenProviderOptions
. This means you are unable to configure the lifetime of each type of token separately. Ideally I would like to be able to set the Password Reset to something like 4 hours and the Confirm Email token to 7 days.I believe I can get around this by subclassing
DataProtectorTokenProvider
andDataProtectionTokenProviderOptions
, and setting the appropriate name viaIdentityOptions.Token.EmailConfirmationTokenProvider
but it is far from a pretty solution.The text was updated successfully, but these errors were encountered: