-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted all to file-scoped-namespaces
- Loading branch information
1 parent
fc9bfc9
commit 966fba4
Showing
29 changed files
with
1,031 additions
and
995 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
namespace Revoke.NET.Akavache; | ||
|
||
using System; | ||
using System.Reactive.Linq; | ||
using System.Threading.Tasks; | ||
using Akavache; | ||
using Registrations = Akavache.Registrations; | ||
using global::Akavache; | ||
|
||
namespace Revoke.NET.Akavache | ||
public class AkavacheBlackList : IBlackList | ||
{ | ||
public class AkavacheBlackList : IBlackList | ||
private static TimeSpan? _defaultTtl; | ||
private readonly IBlobCache _blackList; | ||
|
||
private AkavacheBlackList(IBlobCache blobcache) | ||
{ | ||
private readonly IBlobCache _blackList; | ||
private static TimeSpan? _defaultTtl; | ||
this._blackList = blobcache; | ||
} | ||
|
||
private AkavacheBlackList(IBlobCache blobcache) | ||
public async Task<bool> Delete(string key) | ||
{ | ||
try | ||
{ | ||
this._blackList = blobcache; | ||
} | ||
await this._blackList.Invalidate(key); | ||
|
||
public static async Task<IBlackList> CreateStoreAsync(string cacheName, IBlobCache blobCache, | ||
TimeSpan? defaultTtl = null) | ||
return true; | ||
} | ||
catch | ||
{ | ||
_defaultTtl = defaultTtl; | ||
Registrations.Start(cacheName); | ||
await blobCache.Vacuum(); | ||
return new AkavacheBlackList(blobCache); | ||
return false; | ||
} | ||
} | ||
|
||
public async Task DeleteAll() | ||
{ | ||
await this._blackList.InvalidateAll(); | ||
} | ||
|
||
public async Task<bool> Delete(string key) | ||
public async Task<bool> IsRevoked(string key) | ||
{ | ||
try | ||
{ | ||
try | ||
{ | ||
await _blackList.Invalidate(key); | ||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
await this._blackList.Vacuum(); | ||
var exist = await this._blackList.Get(key); | ||
|
||
public async Task DeleteAll() | ||
return exist.Length > 0; | ||
} | ||
catch | ||
{ | ||
await _blackList.InvalidateAll(); | ||
return false; | ||
} | ||
} | ||
|
||
public async Task<bool> IsRevoked(string key) | ||
public async Task<bool> Revoke(string key) | ||
{ | ||
try | ||
{ | ||
try | ||
{ | ||
await _blackList.Vacuum(); | ||
var exist = await _blackList.Get(key); | ||
return exist.Length > 0; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
await this._blackList.InsertObject(key, key, DateTimeOffset.Now.Add(_defaultTtl ?? TimeSpan.MaxValue)); | ||
|
||
public async Task<bool> Revoke(string key) | ||
return true; | ||
} | ||
catch | ||
{ | ||
try | ||
{ | ||
await _blackList.InsertObject(key, key, DateTimeOffset.Now.Add(_defaultTtl ?? TimeSpan.MaxValue)); | ||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
public async Task<bool> Revoke(string key, TimeSpan expireAfter) | ||
{ | ||
try | ||
{ | ||
await this._blackList.InsertObject(key, key, DateTimeOffset.Now.Add(expireAfter)); | ||
|
||
public async Task<bool> Revoke(string key, TimeSpan expireAfter) | ||
return true; | ||
} | ||
catch | ||
{ | ||
try | ||
{ | ||
await _blackList.InsertObject(key, key, DateTimeOffset.Now.Add(expireAfter)); | ||
|
||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
public async Task<bool> Revoke(string key, DateTime expireOn) | ||
public async Task<bool> Revoke(string key, DateTime expireOn) | ||
{ | ||
try | ||
{ | ||
try | ||
{ | ||
await _blackList.InsertObject(key, key, expireOn); | ||
|
||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
await this._blackList.InsertObject(key, key, expireOn); | ||
|
||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public static async Task<IBlackList> CreateStoreAsync(string cacheName, IBlobCache blobCache, TimeSpan? defaultTtl = null) | ||
{ | ||
_defaultTtl = defaultTtl; | ||
Registrations.Start(cacheName); | ||
await blobCache.Vacuum(); | ||
|
||
return new AkavacheBlackList(blobCache); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<LangVersion>10.0</LangVersion> | ||
<PackageIcon>revoke.net.png</PackageIcon> | ||
<PackageReadmeFile>readme.md</PackageReadmeFile> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<OutputType>Library</OutputType> | ||
<Version>2.0.0</Version> | ||
<StartupObject /> | ||
<Authors>Chakhoum Ahmed (github.com/rainxh11)</Authors> | ||
<Description>Revoke.NET Akavache Store Extension</Description> | ||
<Copyright>© 2022 Chakhoum Ahmed</Copyright> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<PackageProjectUrl>https://github.com/rainxh11/Revoke.NET</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/rainxh11/Revoke.NET/tree/main/Revoke.NET.Akavache</RepositoryUrl> | ||
<RepositoryType>github</RepositoryType> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<PackageTags>revoke;jwt;token;permission;deny;blacklist;aspnet;logout;expiration;invalidate;ip;mongo;mongodb;store</PackageTags> | ||
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput> | ||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> | ||
<GenerateDocumentationFile>True</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<LangVersion>10.0</LangVersion> | ||
<PackageIcon>revoke.net.png</PackageIcon> | ||
<PackageReadmeFile>readme.md</PackageReadmeFile> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<OutputType>Library</OutputType> | ||
<Version>2.0.0</Version> | ||
<StartupObject/> | ||
<Authors>Chakhoum Ahmed (github.com/rainxh11)</Authors> | ||
<Description>Revoke.NET Akavache Store Extension</Description> | ||
<Copyright>© 2022 Chakhoum Ahmed</Copyright> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<PackageProjectUrl>https://github.com/rainxh11/Revoke.NET</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/rainxh11/Revoke.NET/tree/main/Revoke.NET.Akavache</RepositoryUrl> | ||
<RepositoryType>github</RepositoryType> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<PackageTags>revoke;jwt;token;permission;deny;blacklist;aspnet;logout;expiration;invalidate;ip;mongo;mongodb;store</PackageTags> | ||
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput> | ||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> | ||
<GenerateDocumentationFile>True</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\assets\revoke.net.png" Pack="true" PackagePath="\" /> | ||
<None Include="readme.md" Pack="true" PackagePath="\" /> | ||
<None Include="..\LICENSE" Pack="true" PackagePath="\" /> | ||
<PackageReference Include="akavache" Version="9.0.1" /> | ||
<PackageReference Include="akavache.sqlite3" Version="9.0.1" /> | ||
<PackageReference Include="Revoke.NET" Version="2.0.1" /> | ||
</ItemGroup> | ||
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage"> | ||
<ItemGroup> | ||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" /> | ||
</ItemGroup> | ||
</Target> | ||
<ItemGroup> | ||
<None Include="..\assets\revoke.net.png" Pack="true" PackagePath="\"/> | ||
<None Include="readme.md" Pack="true" PackagePath="\"/> | ||
<None Include="..\LICENSE" Pack="true" PackagePath="\"/> | ||
<PackageReference Include="akavache" Version="9.0.1"/> | ||
<PackageReference Include="akavache.sqlite3" Version="9.0.1"/> | ||
<PackageReference Include="Revoke.NET" Version="2.0.1"/> | ||
</ItemGroup> | ||
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage"> | ||
<ItemGroup> | ||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/> | ||
</ItemGroup> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
namespace Revoke.NET.Akavache; | ||
|
||
using System; | ||
using global::Akavache; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Akavache; | ||
|
||
namespace Revoke.NET.Akavache | ||
public static class RevokeService | ||
{ | ||
public static class RevokeService | ||
public static IServiceCollection AddRevokeAkavacheSQLiteStore(this IServiceCollection services) | ||
{ | ||
public static IServiceCollection AddRevokeAkavacheSQLiteStore(this IServiceCollection services) | ||
{ | ||
return services | ||
.AddSingleton<IBlackList>(provider => AkavacheBlackList | ||
.CreateStoreAsync("RevokeStore", BlobCache.LocalMachine) | ||
.GetAwaiter() | ||
.GetResult()); | ||
} | ||
return services.AddSingleton( | ||
provider => AkavacheBlackList.CreateStoreAsync("RevokeStore", BlobCache.LocalMachine) | ||
.GetAwaiter() | ||
.GetResult()); | ||
} | ||
|
||
public static IServiceCollection AddRevokeAkavacheInMemoryStore(this IServiceCollection services) | ||
{ | ||
return services | ||
.AddSingleton<IBlackList>(provider => AkavacheBlackList | ||
.CreateStoreAsync("RevokeStore", BlobCache.InMemory) | ||
.GetAwaiter() | ||
.GetResult()); | ||
} | ||
public static IServiceCollection AddRevokeAkavacheInMemoryStore(this IServiceCollection services) | ||
{ | ||
return services.AddSingleton( | ||
provider => AkavacheBlackList.CreateStoreAsync("RevokeStore", BlobCache.InMemory) | ||
.GetAwaiter() | ||
.GetResult()); | ||
} | ||
|
||
public static IServiceCollection AddRevokeAkavacheStore(this IServiceCollection services, | ||
Func<IServiceProvider, IBlobCache> configBlobCache) | ||
{ | ||
return services | ||
.AddSingleton<IBlackList>(provider => AkavacheBlackList | ||
.CreateStoreAsync("RevokeStore", configBlobCache(provider)) | ||
.GetAwaiter() | ||
.GetResult()); | ||
} | ||
public static IServiceCollection AddRevokeAkavacheStore(this IServiceCollection services, Func<IServiceProvider, IBlobCache> configBlobCache) | ||
{ | ||
return services.AddSingleton( | ||
provider => AkavacheBlackList.CreateStoreAsync("RevokeStore", configBlobCache(provider)) | ||
.GetAwaiter() | ||
.GetResult()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.