Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
757e39f
chore: #60: adds jwt token validator
iamvladislove Aug 15, 2022
65c7b0c
test(units): #60: adds jwt token validator tests
iamvladislove Aug 15, 2022
220031e
chore: #60: corrects contract for access token generation
iamvladislove Aug 15, 2022
19b448a
chore: #60: adds refresh servie for the core package
iamvladislove Aug 15, 2022
f9bebc2
chore: #60: adds base version of refresh in the core package
iamvladislove Aug 15, 2022
e3013cc
chore: #60: temporary comments the refresh feature in the identity pa…
iamvladislove Aug 16, 2022
99278d5
chore: #60: adds jst token creator
iamvladislove Aug 16, 2022
54822b3
chore: #60: removes unnecessary code
iamvladislove Aug 16, 2022
1c44900
test(units): #60: adds the jwt token creator tests
iamvladislove Aug 16, 2022
e1ac033
chore: #60: changes the jwt token creator contract
iamvladislove Aug 16, 2022
2e8dfc7
chore: #60: adds token type validation in the refresh service
iamvladislove Aug 17, 2022
0725a72
chore: #60: changes the contract of the jwt token creator
iamvladislove Aug 17, 2022
799a3b3
chore: #60: implements refresh token manager for the core package
iamvladislove Aug 17, 2022
f8ba385
build(examples): #60: adds a project example for the refresh feature
iamvladislove Aug 17, 2022
c2f332b
chore(middlewares): #60: adds errors handling on different exceptions
iamvladislove Aug 18, 2022
2e496c3
chore: #60: adds shared library to use refresh feature in the both pr…
iamvladislove Aug 18, 2022
7d536f2
style(editorconfig): #60: changes the end of lines
iamvladislove Aug 18, 2022
26cf4f9
build(solution): #60: removes .netcore3.0 support
iamvladislove Aug 18, 2022
f6358d3
build(examles): #60: removes the .netcore3.0 example
iamvladislove Aug 18, 2022
14508ad
chore(shared): #60: sets public modifier for all files in the shared …
iamvladislove Aug 22, 2022
9218597
chore: #60: starts to split core and shared projects
iamvladislove Aug 22, 2022
1033b62
chore: #60: continues to split core and shared projects
iamvladislove Aug 23, 2022
ec55809
chore: #60: resolves a problem with login middleware registration
iamvladislove Aug 29, 2022
ff25add
chore: #60: enables cookie login middleware
iamvladislove Aug 29, 2022
2873c9e
chore: #60: removes refresh section from shared project
iamvladislove Aug 29, 2022
e12c417
chore: #60: removes unused code
iamvladislove Aug 30, 2022
e1b05aa
chore: #60: adds a .netcore3.1 project example with permissions
iamvladislove Aug 30, 2022
44cb61a
chore: #60: removes unnecessary code
iamvladislove Aug 30, 2022
7f3ad34
chore: #60: adds a project example for presenting custom credentials …
iamvladislove Aug 30, 2022
1b51a86
chore: #60: adds interface for authentication options
iamvladislove Aug 31, 2022
7210889
chore: #60: adds interface for the refresh endpoint options
iamvladislove Aug 31, 2022
a6b8159
chore: #60: removes unnecessary options from the shared project
iamvladislove Aug 31, 2022
a741a9a
chore: #60: moves internal classes in the core project into a separat…
iamvladislove Aug 31, 2022
6514bf5
chore: #60: changes the examples folder structure for .netcore3.1 pro…
iamvladislove Aug 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indent_style = space
tab_width = 4

# New line preferences
end_of_line = crlf
end_of_line = lf
insert_final_newline = false


Expand Down
57 changes: 40 additions & 17 deletions AspNetCore.JwtAuthentication.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore5.0.Permissi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore5.0.WithCredentialsValidator", "Examples\Example.NetCore5.0.WithCredentialsValidator\Example.NetCore5.0.WithCredentialsValidator.csproj", "{E2BC2C97-161E-41E4-B224-DFC62AD56768}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore3.0.BaseAuthentication", "Examples\Example.NetCore3.0.BaseAuthentication\Example.NetCore3.0.BaseAuthentication.csproj", "{6AB1E6C4-563A-4447-8024-6C31C9A45141}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore3.1.BaseAuthentication", "Examples\Example.NetCore3.1.BaseAuthentication\Example.NetCore3.1.BaseAuthentication.csproj", "{43D3813D-CD36-46A7-86EF-CD6CF0A9A9BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore5.0.CookiesBasedAuthentication", "Examples\Example.NetCore5.0.CookiesBasedAuthentication\Example.NetCore5.0.CookiesBasedAuthentication.csproj", "{32E74378-AAF5-4CA6-8633-30997453E58A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtAuthentication.Identity", "JwtAuthentication.Identity\JwtAuthentication.Identity.csproj", "{60A8C4FC-D6DC-4C5B-9FA9-6F81F55F3667}"
Expand All @@ -38,8 +34,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore6.0.BaseAuth
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetCore5.0", "NetCore5.0", "{7A925031-2656-4CEB-821A-D76739E0E5A2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetCore3.", "NetCore3.", "{614DB4C6-A4BE-4BBF-B385-C34985CA1FC3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetCore6.0", "NetCore6.0", "{4FF83CB3-A634-4D07-BEE0-B5391B86F071}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore6.0.AuthenticationUsingIdentityUser", "Examples\Example.NetCore6.0.AuthenticationUsingIdentityUser\Example.NetCore6.0.AuthenticationUsingIdentityUser.csproj", "{28707296-5273-471B-89FB-FA3D6C62CA67}"
Expand All @@ -60,6 +54,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore6.0.RefreshT
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore5.0.RefreshTokenWithConfidenceInterval", "Examples\Example.NetCore5.0.RefreshTokenWithConfidenceInterval\Example.NetCore5.0.RefreshTokenWithConfidenceInterval.csproj", "{F0E28B79-7957-444F-B437-D2EEC072A6DE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtAuthentication.Shared", "JwtAuthentication.Shared\JwtAuthentication.Shared.csproj", "{E1952561-A7CD-45C3-B9D0-AC9B92A194CC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{D7304D43-BEFB-418C-866B-BCDBF4944DAE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetCore3.1", "NetCore3.1", "{89FFB48D-FF56-4FC0-BB01-47855CD3A1A0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore3.1.WithCredentialsValidator", "Examples\Core\NetCore3.1\Example.NetCore.3.1.WithCredentialsValidator\Example.NetCore3.1.WithCredentialsValidator.csproj", "{A092BCEE-7B25-4DFB-9DB7-D29399750095}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore3.1.AuthenticationWithRefreshToken", "Examples\Core\NetCore3.1\Example.NetCore3.1.AuthenticationWithRefreshToken\Example.NetCore3.1.AuthenticationWithRefreshToken.csproj", "{2B5AEDED-B2D5-45C1-865E-FEC5C62E7B6C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore3.1.BaseAuthentication", "Examples\Core\NetCore3.1\Example.NetCore3.1.BaseAuthentication\Example.NetCore3.1.BaseAuthentication.csproj", "{996BF68D-03EB-466D-8E79-CFEBD13D255D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.NetCore3.1.PermissionBasedAuthentication", "Examples\Core\NetCore3.1\Example.NetCore3.1.PermissionBasedAuthentication\Example.NetCore3.1.PermissionBasedAuthentication.csproj", "{47427766-B40C-4C8C-80F4-4EFD57AABBE0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -82,14 +90,6 @@ Global
{E2BC2C97-161E-41E4-B224-DFC62AD56768}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2BC2C97-161E-41E4-B224-DFC62AD56768}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2BC2C97-161E-41E4-B224-DFC62AD56768}.Release|Any CPU.Build.0 = Release|Any CPU
{6AB1E6C4-563A-4447-8024-6C31C9A45141}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AB1E6C4-563A-4447-8024-6C31C9A45141}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AB1E6C4-563A-4447-8024-6C31C9A45141}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AB1E6C4-563A-4447-8024-6C31C9A45141}.Release|Any CPU.Build.0 = Release|Any CPU
{43D3813D-CD36-46A7-86EF-CD6CF0A9A9BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43D3813D-CD36-46A7-86EF-CD6CF0A9A9BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43D3813D-CD36-46A7-86EF-CD6CF0A9A9BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43D3813D-CD36-46A7-86EF-CD6CF0A9A9BC}.Release|Any CPU.Build.0 = Release|Any CPU
{32E74378-AAF5-4CA6-8633-30997453E58A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32E74378-AAF5-4CA6-8633-30997453E58A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32E74378-AAF5-4CA6-8633-30997453E58A}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -154,6 +154,26 @@ Global
{F0E28B79-7957-444F-B437-D2EEC072A6DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0E28B79-7957-444F-B437-D2EEC072A6DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0E28B79-7957-444F-B437-D2EEC072A6DE}.Release|Any CPU.Build.0 = Release|Any CPU
{E1952561-A7CD-45C3-B9D0-AC9B92A194CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1952561-A7CD-45C3-B9D0-AC9B92A194CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1952561-A7CD-45C3-B9D0-AC9B92A194CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1952561-A7CD-45C3-B9D0-AC9B92A194CC}.Release|Any CPU.Build.0 = Release|Any CPU
{A092BCEE-7B25-4DFB-9DB7-D29399750095}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A092BCEE-7B25-4DFB-9DB7-D29399750095}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A092BCEE-7B25-4DFB-9DB7-D29399750095}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A092BCEE-7B25-4DFB-9DB7-D29399750095}.Release|Any CPU.Build.0 = Release|Any CPU
{2B5AEDED-B2D5-45C1-865E-FEC5C62E7B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B5AEDED-B2D5-45C1-865E-FEC5C62E7B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B5AEDED-B2D5-45C1-865E-FEC5C62E7B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B5AEDED-B2D5-45C1-865E-FEC5C62E7B6C}.Release|Any CPU.Build.0 = Release|Any CPU
{996BF68D-03EB-466D-8E79-CFEBD13D255D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{996BF68D-03EB-466D-8E79-CFEBD13D255D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{996BF68D-03EB-466D-8E79-CFEBD13D255D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{996BF68D-03EB-466D-8E79-CFEBD13D255D}.Release|Any CPU.Build.0 = Release|Any CPU
{47427766-B40C-4C8C-80F4-4EFD57AABBE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47427766-B40C-4C8C-80F4-4EFD57AABBE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47427766-B40C-4C8C-80F4-4EFD57AABBE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47427766-B40C-4C8C-80F4-4EFD57AABBE0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -162,16 +182,13 @@ Global
{36F676C3-2C5F-4727-8BE2-8F759C2A3FBE} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{51E0C282-0942-4367-95EB-F248E80A5D6F} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{E2BC2C97-161E-41E4-B224-DFC62AD56768} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{6AB1E6C4-563A-4447-8024-6C31C9A45141} = {614DB4C6-A4BE-4BBF-B385-C34985CA1FC3}
{43D3813D-CD36-46A7-86EF-CD6CF0A9A9BC} = {614DB4C6-A4BE-4BBF-B385-C34985CA1FC3}
{32E74378-AAF5-4CA6-8633-30997453E58A} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{1DF1D001-0194-4CD8-82DD-40AF57FC1432} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{12915347-991A-4EA0-983D-03121E1C527B} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{8BF217FB-7AB4-4056-8186-2BDE9F3C99EC} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{EF8EF2D5-9483-400E-B938-ADDB467BF300} = {ADBF0A06-FF69-40A6-8F32-2F188AE1B6A4}
{DDA26737-950C-4B23-B66A-1733FB482A29} = {4FF83CB3-A634-4D07-BEE0-B5391B86F071}
{7A925031-2656-4CEB-821A-D76739E0E5A2} = {ADBF0A06-FF69-40A6-8F32-2F188AE1B6A4}
{614DB4C6-A4BE-4BBF-B385-C34985CA1FC3} = {ADBF0A06-FF69-40A6-8F32-2F188AE1B6A4}
{4FF83CB3-A634-4D07-BEE0-B5391B86F071} = {ADBF0A06-FF69-40A6-8F32-2F188AE1B6A4}
{28707296-5273-471B-89FB-FA3D6C62CA67} = {4FF83CB3-A634-4D07-BEE0-B5391B86F071}
{5AE1CC8C-80A2-46AF-A02E-BE129080F489} = {4FF83CB3-A634-4D07-BEE0-B5391B86F071}
Expand All @@ -182,6 +199,12 @@ Global
{C617F7DD-6E7E-4B5D-8766-C82C37EFFF6E} = {4FF83CB3-A634-4D07-BEE0-B5391B86F071}
{ABDD94F3-DF9E-47B2-813F-935C54C8DEA7} = {4FF83CB3-A634-4D07-BEE0-B5391B86F071}
{F0E28B79-7957-444F-B437-D2EEC072A6DE} = {7A925031-2656-4CEB-821A-D76739E0E5A2}
{D7304D43-BEFB-418C-866B-BCDBF4944DAE} = {ADBF0A06-FF69-40A6-8F32-2F188AE1B6A4}
{89FFB48D-FF56-4FC0-BB01-47855CD3A1A0} = {D7304D43-BEFB-418C-866B-BCDBF4944DAE}
{A092BCEE-7B25-4DFB-9DB7-D29399750095} = {89FFB48D-FF56-4FC0-BB01-47855CD3A1A0}
{2B5AEDED-B2D5-45C1-865E-FEC5C62E7B6C} = {89FFB48D-FF56-4FC0-BB01-47855CD3A1A0}
{996BF68D-03EB-466D-8E79-CFEBD13D255D} = {89FFB48D-FF56-4FC0-BB01-47855CD3A1A0}
{47427766-B40C-4C8C-80F4-4EFD57AABBE0} = {89FFB48D-FF56-4FC0-BB01-47855CD3A1A0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C2026BF9-DACC-4EA4-AF04-B8A590EA38BF}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Example.NetCore3._0.BaseAuthentication.Controllers
namespace Example.NetCore3._1.WithCredentialsValidator.Controllers
{
[ApiController]
[Route("[controller]")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Threading.Tasks;
using TourmalineCore.AspNetCore.JwtAuthentication.Core.Contracts;

namespace Example.NetCore3._1.WithCredentialsValidator
{
public class CustomUserCredentialsValidator : UserCredentialsValidator
{
private const string Login = "User";
private const string Password = "User";

public override Task<bool> ValidateUserCredentials(string login, string password)
{
return Task.FromResult(login == Login && password == Password);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Example.NetCore._3._1.WithCredentialsValidator</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\JwtAuthentication.Core\JwtAuthentication.Core.csproj" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Example.NetCore3._0.BaseAuthentication
namespace Example.NetCore3._1.WithCredentialsValidator
{
public class Program
{
Expand All @@ -16,4 +16,4 @@ public static IHostBuilder CreateHostBuilder(string[] args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:36212",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "example",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Example.NetCore3._1.WithCredentialsValidator": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "example",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using TourmalineCore.AspNetCore.JwtAuthentication.Core;
using TourmalineCore.AspNetCore.JwtAuthentication.Core.Options;

namespace Example.NetCore3._0.BaseAuthentication
namespace Example.NetCore3._1.WithCredentialsValidator
{
public class Startup
{
Expand All @@ -19,7 +19,9 @@ public Startup(IConfiguration configuration)

public void ConfigureServices(IServiceCollection services)
{
services.AddJwtAuthentication(_configuration.GetSection(nameof(AuthenticationOptions)).Get<AuthenticationOptions>());
services
.AddJwtAuthentication(_configuration.GetSection(nameof(AuthenticationOptions)).Get<AuthenticationOptions>())
.AddUserCredentialValidator<CustomUserCredentialsValidator>();

services.AddControllers();
}
Expand All @@ -40,4 +42,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AuthenticationOptions": {
"PublicSigningKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsDwLnM5sbVi326YDsLvMkQLXDKVAaHrJZ/MwkoxF4Hmq4+pu4KojgQyVDtjseXG8UW5wbxW58eXG8V0XgJzsD8zQX2Z1bBawpIeD9sXf/5CFZGif85YFIqS3brqR3ScdGxYHXcwrUMGUCThxe918Q0aNXzdSxGGP2v7ZbtpFhLRyrTXHl4u6k3eyYG7zCkwextnMb9CJuCR7x1ua1V1S0xljAqg5PicFjt0vVSKzPM/Djw7XK84sJXxaet7t4cNtXVJIAyXUMsSli6gg9Cw9CEUSE40iWUR/6wrdUYAchk3vWiBhMmnufwzmFRLKHOH9Fz8buJVSrRfyt7a6S2iN+wIDAQABMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsDwLnM5sbVi326YDsLvMkQLXDKVAaHrJZ/MwkoxF4Hmq4+pu4KojgQyVDtjseXG8UW5wbxW58eXG8V0XgJzsD8zQX2Z1bBawpIeD9sXf/5CFZGif85YFIqS3brqR3ScdGxYHXcwrUMGUCThxe918Q0aNXzdSxGGP2v7ZbtpFhLRyrTXHl4u6k3eyYG7zCkwextnMb9CJuCR7x1ua1V1S0xljAqg5PicFjt0vVSKzPM/Djw7XK84sJXxaet7t4cNtXVJIAyXUMsSli6gg9Cw9CEUSE40iWUR/6wrdUYAchk3vWiBhMmnufwzmFRLKHOH9Fz8buJVSrRfyt7a6S2iN+wIDAQAB",
"PrivateSigningKey": "MIIEowIBAAKCAQEAsDwLnM5sbVi326YDsLvMkQLXDKVAaHrJZ/MwkoxF4Hmq4+pu4KojgQyVDtjseXG8UW5wbxW58eXG8V0XgJzsD8zQX2Z1bBawpIeD9sXf/5CFZGif85YFIqS3brqR3ScdGxYHXcwrUMGUCThxe918Q0aNXzdSxGGP2v7ZbtpFhLRyrTXHl4u6k3eyYG7zCkwextnMb9CJuCR7x1ua1V1S0xljAqg5PicFjt0vVSKzPM/Djw7XK84sJXxaet7t4cNtXVJIAyXUMsSli6gg9Cw9CEUSE40iWUR/6wrdUYAchk3vWiBhMmnufwzmFRLKHOH9Fz8buJVSrRfyt7a6S2iN+wIDAQABAoIBAQCvue/KV3p+Pex2tD8RxvDf13kfPtfOVkDlyfQw7HXwsuDXijctBfmJAEbRGzQQlHw2pmyuF3fl4DxTB4Qb1lz8FDniJoQHV0ijhgzrz7rfVffsevajKH/OX3gYjShM4GeBTqHhwWefiqZV21YtMFhrrLniq4N4FeAfeebNRg/zlWEigraxqAWb4cplnxBE3qOBECKXdF/B8uhp743BU/2HLSO5BUdhtPlN3FKoYdyqtrKyNO2z7rC+Gk8tNd+KbMHDUMiOQXzbXkpsXYKAug9iTW+gxZG/bNyzGNrJBFrUYb1fP4iZphbxBJgobNYJBKA565cAX/wI5lFakTBB0YAhAoGBAOk0TyV0dA8WJ6NrWmRUBKsKvkSREhBveW+P3LtA8a1IgQf4K6ohIfcq9w/+nRvTLPIxo67FcqEyzVUu9TOafzIi59w4RBWG/HKOZ5lvIVicbuPyclPVWyC+9bMMgWEJy9wGwE+fGh3AvAA4PXNBcjOqfT0sSF9PBUo5qN11Q/qHAoGBAMF2IL+cXgPiUta4XoMh14ksJiwHtZeMkj+kauU3rctDITSkIGMFp4q0W5UUSG1yPcW/++rMQfuAjCZotdNpbQT+g+KfG44DMT5W7nRgv60S0/6X/OoLIhCue19yLMVzFpai0YEH+s24/XNnwl53K34G1zVMCsZcIuIng8SZVintAoGAJP/1pr2pRFOBin4X418pNnIH6h0SPqVRIRA0N0mAjru4LSmE1ANZvjuE43bEOovwz6Rskegl3cmPpnpC0SMsFypOmzQaKUg3eX16lm95XPPE7EmlNgPd534kwXm0dU72lzxC+t8FZ78SlP5XUZgKpIPiRvhlqymAb1xinHBkjrUCgYAB144YRPTgNJd1U+wSc5AJzlHOuYQRHVWHJZme9RjChrEaPzXPu44M1ArLMJY/9IaCC4HqimdWbbLn6rdQfAB9u66lyb4JbB5b6Zf7o7Avha5fDjNqRxDb981U61Fhz+a3KHW2NM0+iDRhlOtU2u2fFZGXAFJZ8Saj4JxwksUvQQKBgEQ1TAW/INhWSkEW8vGeLnjV+rxOx8EJ9ftVCRaQMlDEDlX0n7BZeQrQ1pBxwL0FSTrUQdD02MsWshrhe0agKsw2Yaxn8gYs1v9HMloS4Q3L2zl8pi7R3yx72RIcdnS4rqGXeO5t8dm305Yz2RHhqtkBmpFBssSEYCY/tUDmsQVU"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Example.NetCore3._1.AuthenticationWithRefreshToken.Controllers
{
[ApiController]
[Route("[controller]")]
public class ExampleController : ControllerBase
{
private static readonly string[] Summaries =
{
"Freezing",
"Bracing",
"Chilly",
"Cool",
"Mild",
"Warm",
"Balmy",
"Hot",
"Sweltering",
"Scorching",
};

[Authorize]
[HttpGet]
public IEnumerable<object> Get()
{
return Summaries;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Example.NetCore3._1.AuthenticationWithRefreshToken</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\JwtAuthentication.Core\JwtAuthentication.Core.csproj" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Example.NetCore3._1.AuthenticationWithRefreshToken
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55870/",
"sslPort": 44324
"applicationUrl": "http://localhost:36255",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Example.NetCore3._0.BaseAuthentication": {
"Example.NetCore3._1.AuthenticationWithRefreshToken": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
Expand All @@ -24,4 +26,4 @@
"applicationUrl": "http://localhost:5000"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using TourmalineCore.AspNetCore.JwtAuthentication.Core;
using TourmalineCore.AspNetCore.JwtAuthentication.Core.Options;

namespace Example.NetCore3._1.AuthenticationWithRefreshToken
{
public class Startup
{
private readonly IConfiguration _configuration;

public Startup(IConfiguration configuration)
{
_configuration = configuration;
}

public void ConfigureServices(IServiceCollection services)
{
services
.AddJwtAuthentication(_configuration.GetSection(nameof(AuthenticationOptions)).Get<AuthenticationOptions>())
.AddLoginWithRefresh();

services.AddControllers();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRouting();

app
.UseDefaultLoginMiddleware()
.UseJwtAuthentication();

app.UseRefreshTokenMiddleware();

app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
}
}
Loading