-
How can I modify the OpenId defualt token expire time? In old version of Orchard Core, I cant call
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 6 replies
-
Duplicate of #7035 |
Beta Was this translation helpful? Give feedback.
-
Oops didn't see that #7035 is a discussion, not an issue, reopen it |
Beta Was this translation helpful? Give feedback.
-
@jtkech I have deleted the discussion, it's a mistake... |
Beta Was this translation helpful? Give feedback.
-
Any people know ? |
Beta Was this translation helpful? Give feedback.
-
I resolved this issue , add an
|
Beta Was this translation helpful? Give feedback.
-
FWIW, using such a long expiration date is a very bad idea and something I'd strongly discourage. Why not using refresh tokens? |
Beta Was this translation helpful? Give feedback.
-
Is there any way we can extend the expiration time on this issue without modifying the OrchardCore source code? |
Beta Was this translation helpful? Give feedback.
-
The default time is 1 hour, which is really short, |
Beta Was this translation helpful? Give feedback.
-
The token life cycle is fine, but if you want to implement refreshing tokens, you need some extra work。 internal class UserTokenLifeTimeClaimsProvider : IUserClaimsProvider
{
private readonly IHttpContextAccessor _httpContextAccessor;
public UserTokenLifeTimeClaimsProvider(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public Task GenerateAsync(IUser user, ClaimsIdentity claims)
{
var lifeTime = TimeSpan.FromHours(10);
if (_httpContextAccessor.HttpContext.Request.Form["rememberme"] == "true")
{
lifeTime = TimeSpan.FromDays(7);
}
claims.AddClaim(new Claim("oi_act_lft",
lifeTime.TotalSeconds.ToString(CultureInfo.InvariantCulture)));
return Task.FromResult(claims);
}
} |
Beta Was this translation helpful? Give feedback.
-
Oh, I was wrong about one thing,
|
Beta Was this translation helpful? Give feedback.
I resolved this issue , add an
principal.SetAccessTokenLifetime
call beforeSingIn
.