Skip to content

Commit 06b6ad4

Browse files
committed
+Fixed ASP.NET Core Extension Bug
+Fixed a critical bug preventing MongoDB Extension Service Iinitialization
1 parent af02a38 commit 06b6ad4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+892
-108
lines changed

Revoke.NET.Akavache/Revoke.NET.Akavache.csproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageReadmeFile>readme.md</PackageReadmeFile>
88
<PackageLicenseFile>LICENSE</PackageLicenseFile>
99
<OutputType>Library</OutputType>
10-
<Version>1.0.4</Version>
10+
<Version>1.0.6</Version>
1111
<StartupObject />
1212
<Authors>Chakhoum Ahmed (github.com/rainxh11)</Authors>
1313
<Description>Revoke.NET Akavache Store Extension</Description>
@@ -19,6 +19,8 @@
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2020
<PackageTags>revoke;jwt;token;permission;deny;blacklist;aspnet;logout;expiration;invalidate;ip;mongo;mongodb;store</PackageTags>
2121
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
22+
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
23+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2224
</PropertyGroup>
2325

2426
<ItemGroup>
@@ -27,7 +29,7 @@
2729
<None Include="LICENSE" Pack="true" PackagePath="" />
2830
<PackageReference Include="akavache" Version="8.1.1" />
2931
<PackageReference Include="akavache.sqlite3" Version="8.1.1" />
30-
<PackageReference Include="Revoke.NET" Version="1.0.3" />
32+
<PackageReference Include="Revoke.NET" Version="1.0.5" />
3133
</ItemGroup>
3234
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
3335
<ItemGroup>

Revoke.NET.AspNetCore/Revoke - Backup.NET.AspNetCore.csproj

-39
This file was deleted.

Revoke.NET.AspNetCore/Revoke.NET.AspNetCore.csproj

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageReadmeFile>readme.md</PackageReadmeFile>
88
<PackageLicenseFile>LICENSE</PackageLicenseFile>
99
<OutputType>Library</OutputType>
10-
<Version>1.0.5</Version>
10+
<Version>1.0.7</Version>
1111
<StartupObject />
1212
<Authors>Chakhoum Ahmed (github.com/rainxh11)</Authors>
1313
<Description>Revoke.NET ASP.NET Core Extension</Description>
@@ -20,16 +20,17 @@
2020
<PackageTags>revoke;jwt;token;permission;deny;blacklist;aspnet;logout;expiration;invalidate;ip</PackageTags>
2121
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
2222
<Nullable>annotations</Nullable>
23+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2324
</PropertyGroup>
2425
<ItemGroup>
2526
<None Include="assets\revoke.net.png" Pack="true" PackagePath="\" />
2627
<None Include="readme.md" Pack="true" PackagePath="\" />
2728
<None Include="LICENSE" Pack="true" PackagePath="" />
2829
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
29-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
30-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
31-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
32-
<PackageReference Include="Revoke.NET" Version="1.0.3" />
30+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
31+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
32+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
33+
<PackageReference Include="Revoke.NET" Version="1.0.5" />
3334
</ItemGroup>
3435
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
3536
<ItemGroup>

Revoke.NET.AspNetCore/RevokeHttpMiddleware.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
6060
{
6161
if (await store.IsRevoked(revokeKey))
6262
{
63-
var item = await store.Get<IBlackListItem>(revokeKey);
64-
65-
logger.LogInformation(
66-
$"[Revoke.NET] Revoked Access to key: '{revokeKey}', Blacklisting will be lifted on {item.ExpireOn}");
6763
if (responseFunc != null)
6864
{
6965
await responseFunc(context.Response);
@@ -72,6 +68,10 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
7268
{
7369
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
7470
}
71+
72+
73+
logger.LogInformation(
74+
$"[Revoke.NET] Revoked Access to key: '{revokeKey}'");
7575
}
7676
else
7777
{

Revoke.NET.MinimalAPIExample/Revoke.NET.MinimalAPIExample.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
1111
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
1212
<PackageReference Include="Revoke.NET" Version="1.0.3" />
13-
<PackageReference Include="Revoke.NET.AspNetCore" Version="1.0.3" />
1413
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
1514
</ItemGroup>
1615

Revoke.NET.MongoDB/MongoBlackListStore.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace Revoke.NET.MongoDB
88
{
99
public class MongoBlackListStore : IBlackListStore
1010
{
11-
private readonly IMongoCollection<IBlackListItem> blacklist;
11+
private readonly IMongoCollection<BlackListItem> blacklist;
1212

13-
private MongoBlackListStore(IMongoCollection<IBlackListItem> blacklist)
13+
private MongoBlackListStore(IMongoCollection<BlackListItem> blacklist)
1414
{
1515
this.blacklist = blacklist;
1616
}
@@ -22,15 +22,15 @@ public static async Task<IBlackListStore> CreateStoreAsync(string dbName,
2222

2323
var db = client.GetDatabase(dbName);
2424

25-
var keyIndex = Builders<IBlackListItem>.IndexKeys.Ascending(x => x.Key);
26-
var ttlIndex = Builders<IBlackListItem>.IndexKeys.Ascending(x => x.ExpireOn);
25+
var keyIndex = Builders<BlackListItem>.IndexKeys.Ascending(x => x.Key);
26+
var ttlIndex = Builders<BlackListItem>.IndexKeys.Ascending(x => x.ExpireOn);
2727

28-
var collection = db.GetCollection<IBlackListItem>(nameof(IBlackListItem));
28+
var collection = db.GetCollection<BlackListItem>(nameof(BlackListItem));
2929

3030
await collection.Indexes.CreateOneAsync(
31-
new CreateIndexModel<IBlackListItem>(keyIndex, new CreateIndexOptions() { Unique = true }));
31+
new CreateIndexModel<BlackListItem>(keyIndex, new CreateIndexOptions() { Unique = true }));
3232
await collection.Indexes.CreateOneAsync(
33-
new CreateIndexModel<IBlackListItem>(keyIndex,
33+
new CreateIndexModel<BlackListItem>(ttlIndex,
3434
new CreateIndexOptions() { ExpireAfter = TimeSpan.FromMinutes(1) }));
3535

3636
return new MongoBlackListStore(collection);

Revoke.NET.MongoDB/Revoke.NET.MongoDB.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageReadmeFile>readme.md</PackageReadmeFile>
88
<PackageLicenseFile>LICENSE</PackageLicenseFile>
99
<OutputType>Library</OutputType>
10-
<Version>1.0.3</Version>
10+
<Version>1.0.7</Version>
1111
<StartupObject />
1212
<Authors>Chakhoum Ahmed (github.com/rainxh11)</Authors>
1313
<Description>Revoke.NET MongoDB Store Extension</Description>
@@ -19,14 +19,15 @@
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2020
<PackageTags>revoke;jwt;token;permission;deny;blacklist;aspnet;logout;expiration;invalidate;ip;mongo;mongodb;store</PackageTags>
2121
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
22+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2223
</PropertyGroup>
2324

2425
<ItemGroup>
2526
<None Include="assets\revoke.net.png" Pack="true" PackagePath="\" />
2627
<None Include="readme.md" Pack="true" PackagePath="\" />
2728
<None Include="LICENSE" Pack="true" PackagePath="" />
2829
<PackageReference Include="MongoDB.Driver" Version="2.15.1" />
29-
<PackageReference Include="Revoke.NET" Version="1.0.3" />
30+
<PackageReference Include="Revoke.NET" Version="1.0.5" />
3031
</ItemGroup>
3132
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
3233
<ItemGroup>

Revoke.NET.MonkeyCache/Revoke.NET.EasyCaching.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
56
</PropertyGroup>
67

78
</Project>

Revoke.NET.Redis/RedisBlackListStore.cs

+9-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Task DeleteExpired()
5151
public async Task<T> Get<T>(string key) where T : IBlackListItem
5252
{
5353
var value = await blacklist.StringGetAsync(key);
54-
return JsonSerializer.Deserialize<T>(value.ToString());
54+
return JsonSerializer.Deserialize<T>((string)value.Box());
5555
}
5656

5757
public async Task<IEnumerable<T>> GetAll<T>() where T : IBlackListItem
@@ -60,7 +60,7 @@ public async Task<IEnumerable<T>> GetAll<T>() where T : IBlackListItem
6060
foreach (var key in servers.SelectMany(x => x.Keys()))
6161
{
6262
var value = await blacklist.StringGetAsync(key);
63-
temp.Add(JsonSerializer.Deserialize<T>(value.ToString()));
63+
temp.Add(JsonSerializer.Deserialize<T>((string)value.Box()));
6464
}
6565

6666
return temp;
@@ -74,19 +74,23 @@ public async Task<bool> IsRevoked(string key)
7474

7575
public async Task<bool> Revoke(string key)
7676
{
77-
var value = await blacklist.StringSetAndGetAsync(key, key);
77+
var value = await blacklist.StringSetAndGetAsync(key,
78+
JsonSerializer.Serialize(new BlackListItem(key, DateTimeOffset.MaxValue)));
7879
return value.HasValue;
7980
}
8081

8182
public async Task<bool> Revoke(string key, TimeSpan expireAfter)
8283
{
83-
var value = await blacklist.StringSetAndGetAsync(key, key, expireAfter);
84+
var value = await blacklist.StringSetAndGetAsync(key,
85+
JsonSerializer.Serialize(new BlackListItem(key, DateTimeOffset.MaxValue)), expireAfter);
8486
return value.HasValue;
8587
}
8688

8789
public async Task<bool> Revoke(string key, DateTimeOffset expireOn)
8890
{
89-
var value = await blacklist.StringSetAndGetAsync(key, key, expireOn - DateTimeOffset.Now);
91+
var value = await blacklist.StringSetAndGetAsync(key,
92+
JsonSerializer.Serialize(new BlackListItem(key, DateTimeOffset.MaxValue)),
93+
expireOn - DateTimeOffset.Now);
9094
return value.HasValue;
9195
}
9296

Revoke.NET.Redis/Revoke.NET.Redis.csproj

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageReadmeFile>readme.md</PackageReadmeFile>
88
<PackageLicenseFile>LICENSE</PackageLicenseFile>
99
<OutputType>Library</OutputType>
10-
<Version>1.0.5</Version>
10+
<Version>1.0.6</Version>
1111
<StartupObject />
1212
<Authors>Chakhoum Ahmed (github.com/rainxh11)</Authors>
1313
<Description>Revoke.NET Redis Store Extension</Description>
@@ -19,15 +19,19 @@
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2020
<PackageTags>revoke;jwt;token;permission;deny;blacklist;aspnet;logout;expiration;invalidate;ip;mongo;redis;stackexchange;store</PackageTags>
2121
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
22+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2223
</PropertyGroup>
2324

2425
<ItemGroup>
2526
<None Include="assets\revoke.net.png" Pack="true" PackagePath="\" />
2627
<None Include="readme.md" Pack="true" PackagePath="\" />
2728
<None Include="LICENSE" Pack="true" PackagePath="" />
29+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
30+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
31+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
2832
<PackageReference Include="Revoke.NET" Version="1.0.4" />
2933
<PackageReference Include="StackExchange.Redis" Version="2.5.61" />
30-
<PackageReference Include="System.Text.Json" Version="5.0.0" />
34+
<PackageReference Include="System.Text.Json" Version="6.0.4" />
3135
</ItemGroup>
3236
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
3337
<ItemGroup>

Revoke.NET.sln

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Revoke.NET.Redis", "Revoke.
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Revoke.NET.AspNetCore", "Revoke.NET.AspNetCore\Revoke.NET.AspNetCore.csproj", "{54D90C45-FE00-4AB3-9369-8BBDA03863BA}"
1919
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{BC5B0041-DDA4-470A-92AD-9B6AB67E120D}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
5153
{54D90C45-FE00-4AB3-9369-8BBDA03863BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
5254
{54D90C45-FE00-4AB3-9369-8BBDA03863BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
5355
{54D90C45-FE00-4AB3-9369-8BBDA03863BA}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{BC5B0041-DDA4-470A-92AD-9B6AB67E120D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{BC5B0041-DDA4-470A-92AD-9B6AB67E120D}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{BC5B0041-DDA4-470A-92AD-9B6AB67E120D}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{BC5B0041-DDA4-470A-92AD-9B6AB67E120D}.Release|Any CPU.Build.0 = Release|Any CPU
5460
EndGlobalSection
5561
GlobalSection(SolutionProperties) = preSolution
5662
HideSolutionNode = FALSE

Revoke.NET/Revoke - Backup.NET.csproj

-37
This file was deleted.

Revoke.NET/Revoke.NET.csproj

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageReadmeFile>readme.md</PackageReadmeFile>
88
<PackageLicenseFile>LICENSE</PackageLicenseFile>
99
<OutputType>Library</OutputType>
10-
<Version>1.0.4</Version>
10+
<Version>1.0.5</Version>
1111
<StartupObject />
1212
<Authors>Chakhoum Ahmed (github.com/rainxh11)</Authors>
1313
<Description>.NET Utility to blacklist and revoke access to stuff</Description>
@@ -19,14 +19,15 @@
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2020
<PackageTags>revoke;jwt;token;permission;deny;blacklist;aspnet;logout;expiration;invalidate;ip</PackageTags>
2121
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
22+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2223
</PropertyGroup>
2324
<ItemGroup>
2425
<None Include="assets\revoke.net.png" Pack="true" PackagePath="\" />
2526
<None Include="readme.md" Pack="true" PackagePath="\" />
2627
<None Include="LICENSE" Pack="true" PackagePath="" />
27-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
28-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
29-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
28+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
29+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
30+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
3031
</ItemGroup>
3132
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
3233
<ItemGroup>

Test/Program.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Revoke.NET;
2+
using Revoke.NET.Redis;
3+
4+
var store = await RedisBlackListStore.CreateStoreAsync("localhost");
5+
6+
await store.Revoke("Ahmed", DateTimeOffset.MaxValue);
7+
8+
var item = await store.Get<BlackListItem>("Ahmed");
9+
10+
Console.WriteLine(item.Key);
11+
12+
Console.ReadKey();

Test/Test.csproj

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
12+
<PackageReference Include="Revoke.NET" Version="1.0.5" />
13+
<PackageReference Include="Revoke.NET.Redis" Version="1.0.6" />
14+
</ItemGroup>
15+
16+
</Project>

assets/revoke.net.ico

179 KB
Binary file not shown.

docfx/_site/.dependencymap.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"dependencies":{"index.md":[{"source":"toc.yml","type":"metadata"}],"toc.yml":[{"source":"index.md","type":"file"}]}}

0 commit comments

Comments
 (0)