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

The 'oi_act_lft' claim present in the specified principal is malformed or isn't of the expected type #15526

Closed
hyzx86 opened this issue Mar 16, 2024 · 5 comments
Labels

Comments

@hyzx86
Copy link
Contributor

hyzx86 commented Mar 16, 2024

Describe the bug

To Reproduce

Steps to reproduce the behavior:

My application worked fine when using oc 1.8, but after upgrading to 1.9 preivew, the token api threw 500 error codes

OpenIdServerSettings

        "OpenIdServerSettings": {
            "AccessTokenFormat": 1,
            "DisableAccessTokenEncryption": true,
            "AuthorizationEndpointPath": "/connect/authorize",
            "LogoutEndpointPath": "/connect/logout",
            "TokenEndpointPath": "/connect/token",
            "UserinfoEndpointPath": "/connect/userinfo",
            "IntrospectionEndpointPath": "/connect/introspect",
            "RevocationEndpointPath": "/connect/revoke",
            "AllowPasswordFlow": false,
            "AllowClientCredentialsFlow": false,
            "AllowAuthorizationCodeFlow": true,
            "AllowRefreshTokenFlow": true,
            "AllowHybridFlow": false,
            "AllowImplicitFlow": false,
            "DisableRollingRefreshTokens": false,
            "UseReferenceAccessTokens": true,
            "RequireProofKeyForCodeExchange": false
        },

OpenId Application Settings

{
    "ApplicationId": "fc34e93a3a424a5db77db9f5b54bfef9",
    "ClientId": "easyoc_antd_client",
    "ConsentType": "implicit",
    "DisplayName": "easyoc_antd_client",
    "DisplayNames": {},
    "Id": 1,
    "Permissions": [
        "ept:logout",
        "gt:authorization_code",
        "gt:refresh_token",
        "ept:authorization",
        "ept:token",
        "rst:code",
        "scp:permission",
        "scp:email",
        "scp:offline_access",
        "scp:roles",
        "scp:profile",
        "scp:openid"
    ],
    "PostLogoutRedirectUris": [
        "http://salesportal.localhost:2688/auth/logout_redirect"
    ],
    "RedirectUris": [
        "http://salesportal.localhost:2688/auth/redirect"
    ],
    "Requirements": [],
    "Roles": [],
    "Settings": {},
    "Type": "public"
}

Expected behavior

Expect to get the Token correctly

Screenshots

Request:
image

Response:
image

Logs

 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Routing.EndpointMiddleware|INFO|Executing endpoint 'OrchardCore.OpenId.Controllers.AccessController.Token (OrchardCore.OpenId)' 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|INFO|Route matched with {area = "OrchardCore.OpenId", action = "Token", controller = "Access", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Token() on controller OrchardCore.OpenId.Controllers.AccessController (OrchardCore.OpenId). 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|DEBUG|Execution plan of authorization filters (in the following order): Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.AutoValidateAntiforgeryTokenAuthorizationFilter 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|DEBUG|Execution plan of resource filters (in the following order): Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.SaveTempDataFilter, OrchardCore.Admin.AdminZoneFilter 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|DEBUG|Execution plan of action filters (in the following order): Microsoft.AspNetCore.Mvc.Filters.ControllerActionFilter (Order: -2147483648), Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter (Order: -3000), OrchardCore.DisplayManagement.ModelBinding.ModelBinderAccessorFilter, OrchardCore.DisplayManagement.Notify.NotifyFilter, OrchardCore.DisplayManagement.Razor.RazorViewActionFilter, EasyOC.Core.Authorization.Permissions.EOCAuthorizationFilter, EasyOC.Core.ResultWaper.UnifyResult.SucceededUnifyResultFilter (Order: 8888), OrchardCore.Admin.AdminFilter (Order: 0), OrchardCore.Workflows.Http.Filters.WorkflowActionFilter 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|DEBUG|Execution plan of exception filters (in the following order): EasyOC.Core.Filter.FriendlyExceptionFilter (Order: 999999) 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|DEBUG|Execution plan of result filters (in the following order): Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.SaveTempDataFilter, OrchardCore.DisplayManagement.Notify.NotifyFilter, OrchardCore.Admin.AdminFilter (Order: 0), OrchardCore.Admin.AdminMenuFilter, OrchardCore.Layers.Services.LayerFilter, Microsoft.AspNetCore.Mvc.ProducesAttribute (Order: 0) 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|DEBUG|Executing controller factory for controller OrchardCore.OpenId.Controllers.AccessController (OrchardCore.OpenId) 
2024-03-17 02:24:02.2166|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|DEBUG|Executed controller factory for controller OrchardCore.OpenId.Controllers.AccessController (OrchardCore.OpenId) 
2024-03-17 02:24:02.2318|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler|DEBUG|AuthenticationScheme: OpenIddict.Server.AspNetCore was successfully authenticated. 
2024-03-17 02:24:02.2472|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||YesSql|DEBUG|SELECT TOP (1) [Document].* FROM [Document] INNER JOIN [UserIndex] AS [UserIndex_a1] ON [UserIndex_a1].[DocumentId] = [Document].[Id] WHERE ([UserIndex_a1].[UserId] = @p0) 
2024-03-17 02:24:02.2472|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||YesSql|DEBUG|SELECT [OpenId_Document].* FROM [OpenId_Document] INNER JOIN (SELECT [OpenId_Document].[Id] FROM [OpenId_Document] INNER JOIN [OpenId_OpenIdScopeIndex] AS [OpenIdScopeIndex_a1] ON [OpenIdScopeIndex_a1].[DocumentId] = [OpenId_Document].[Id] WHERE [OpenIdScopeIndex_a1].[Name] IN (@p0, @p1, @p2, @p3, @p4)  GROUP BY [OpenId_Document].[Id]) AS [IndexQuery] ON [IndexQuery].[Id] = [OpenId_Document].[Id] 
2024-03-17 02:24:02.2472|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.SignInResult|INFO|Executing SignInResult with authentication scheme (OpenIddict.Server.AspNetCore) and the following principal: System.Security.Claims.ClaimsPrincipal. 
2024-03-17 02:24:02.2472|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||OpenIddict.Server.OpenIddictServerDispatcher|DEBUG|The event OpenIddict.Server.OpenIddictServerEvents+ProcessSignInContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ResolveHostSignInProperties. 
2024-03-17 02:24:02.2472|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||OpenIddict.Server.OpenIddictServerDispatcher|DEBUG|An exception was thrown by OpenIddict.Server.OpenIddictServerHandlers+ValidateSignInDemand while handling the OpenIddict.Server.OpenIddictServerEvents+ProcessSignInContext event. System.InvalidOperationException: The 'oi_act_lft' claim present in the specified principal is malformed or isn't of the expected type.
   at OpenIddict.Server.OpenIddictServerHandlers.ValidateSignInDemand.HandleAsync(ProcessSignInContext context)
   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)    at OpenIddict.Server.OpenIddictServerHandlers.ValidateSignInDemand.HandleAsync(ProcessSignInContext context)
   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
2024-03-17 02:24:02.2472|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker|INFO|Executed action OrchardCore.OpenId.Controllers.AccessController.Token (OrchardCore.OpenId) in 33.9016ms 
2024-03-17 02:24:02.2472|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Routing.EndpointMiddleware|INFO|Executed endpoint 'OrchardCore.OpenId.Controllers.AccessController.Token (OrchardCore.OpenId)' 
2024-03-17 02:24:02.2738|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware|ERROR|An unhandled exception has occurred while executing the request. System.InvalidOperationException: The 'oi_act_lft' claim present in the specified principal is malformed or isn't of the expected type.
   at OpenIddict.Server.OpenIddictServerHandlers.ValidateSignInDemand.HandleAsync(ProcessSignInContext context)
   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
   at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler.SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties)
   at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at OrchardCore.Apis.GraphQL.GraphQLMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at OrchardCore.ContentPreview.PreviewStartupFilter.<>c.<<Configure>b__0_1>d.MoveNext()
--- End of stack trace from previous location ---
   at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
   at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)    at OpenIddict.Server.OpenIddictServerHandlers.ValidateSignInDemand.HandleAsync(ProcessSignInContext context)
   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
   at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler.SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties)
   at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at OrchardCore.Apis.GraphQL.GraphQLMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at OrchardCore.ContentPreview.PreviewStartupFilter.<>c.<<Configure>b__0_1>d.MoveNext()
--- End of stack trace from previous location ---
   at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
   at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
2024-03-17 02:24:02.2819|SalesProtalDev|00-b98220b6b0d0d8896aecf6150be88438-deddafb9afd03b5e-00||Microsoft.AspNetCore.Server.Kestrel.Connections|DEBUG|Connection id "0HN25SNU1A0LU" completed keep alive response. 
@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 16, 2024

Sorry, this is my problem ~~ The code uses oi_act_lft

@hyzx86 hyzx86 closed this as completed Mar 16, 2024
@kevinchalet
Copy link
Member

@hyzx86 were you adding the oi_act_lft claim manually instead of using the SetAccessTokenLifetime() extension?

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 17, 2024

@hyzx86 were you adding the oi_act_lft claim manually instead of using the SetAccessTokenLifetime() extension?

Yes, there is. I made a custom UserClaimsProvider to automatically extend the validity of token after the user logs in.

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 17, 2024

I deleted them for the time , but is there a better way to specify this expiration date? It's an hour now, and I hope it can be extended to one week.

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 17, 2024

@kevinchalet , Thanks for your advice, the problem has been solved perfectly 👍

    public 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);
            var request = _httpContextAccessor.HttpContext.Request;
            if (request.Path.Value.ToLower().EndsWith("token") && request.Method.ToUpper() == "POST")
            {
                if (request.Form["rememberMe"] == "true")
                {
                    lifeTime = TimeSpan.FromDays(7);
                }
                //claims.SetAccessTokenLifetime(lifeTime);
                claims.SetRefreshTokenLifetime(lifeTime);

            }
            return Task.FromResult(claims);
        }

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants