Browse Source
Merge pull request #23381 from abpframework/HttpContextAbpAccessTokenProvider
Check user authentication before providing access token
pull/23390/head
Engincan VESKE
7 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
7 additions and
0 deletions
-
framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextAbpAccessTokenProvider.cs
|
|
|
@ -1,8 +1,10 @@ |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authentication; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
using Volo.Abp.Http.Client.Authentication; |
|
|
|
using Volo.Abp.Users; |
|
|
|
|
|
|
|
namespace Volo.Abp.Http.Client.IdentityModel.Web; |
|
|
|
|
|
|
|
@ -24,6 +26,11 @@ public class HttpContextAbpAccessTokenProvider : IAbpAccessTokenProvider, ITrans |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
if (!httpContext.RequestServices.GetRequiredService<ICurrentUser>().IsAuthenticated) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return await httpContext.GetTokenAsync("access_token"); |
|
|
|
} |
|
|
|
} |
|
|
|
|