.net-core

run additional logic besides [Authorize] annotation

不羁岁月 提交于 2021-02-10 00:14:30
问题 I'm using the Microsoft.AspNetCore.Authentication.JwtBearer and System.IdentityModel.Tokens.Jwt for my .NET Core project. Whenever I generate a new token I store that to the database. When a user signs out, I remove it from the database to invalidate it (I also remove the expired ones from the database with a job). When a user tries to access a route protected by the [Authorize] annotation I want to check if that token exists in the database. If not, I send a 401. In my Startup in the

run additional logic besides [Authorize] annotation

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 00:12:44
问题 I'm using the Microsoft.AspNetCore.Authentication.JwtBearer and System.IdentityModel.Tokens.Jwt for my .NET Core project. Whenever I generate a new token I store that to the database. When a user signs out, I remove it from the database to invalidate it (I also remove the expired ones from the database with a job). When a user tries to access a route protected by the [Authorize] annotation I want to check if that token exists in the database. If not, I send a 401. In my Startup in the

run additional logic besides [Authorize] annotation

好久不见. 提交于 2021-02-10 00:07:43
问题 I'm using the Microsoft.AspNetCore.Authentication.JwtBearer and System.IdentityModel.Tokens.Jwt for my .NET Core project. Whenever I generate a new token I store that to the database. When a user signs out, I remove it from the database to invalidate it (I also remove the expired ones from the database with a job). When a user tries to access a route protected by the [Authorize] annotation I want to check if that token exists in the database. If not, I send a 401. In my Startup in the

Preprocessor : Get Operating System .Net Core

北城以北 提交于 2021-02-09 15:23:22
问题 I'm writing a class that I wish to use on both Windows & Linux. One of the methods that is in this class is accessing the Windows Registry What I'm hoping to achieve is to somehow disable this particular method from being used when using a Linux machine. First of all I did some research to see if there was something for .Net Core that would allow me to check which operating system is in use, I found this and sure enough that works. When I implemented it into my code when accessing a method, I

Preprocessor : Get Operating System .Net Core

谁都会走 提交于 2021-02-09 15:18:51
问题 I'm writing a class that I wish to use on both Windows & Linux. One of the methods that is in this class is accessing the Windows Registry What I'm hoping to achieve is to somehow disable this particular method from being used when using a Linux machine. First of all I did some research to see if there was something for .Net Core that would allow me to check which operating system is in use, I found this and sure enough that works. When I implemented it into my code when accessing a method, I

Preprocessor : Get Operating System .Net Core

旧街凉风 提交于 2021-02-09 15:15:53
问题 I'm writing a class that I wish to use on both Windows & Linux. One of the methods that is in this class is accessing the Windows Registry What I'm hoping to achieve is to somehow disable this particular method from being used when using a Linux machine. First of all I did some research to see if there was something for .Net Core that would allow me to check which operating system is in use, I found this and sure enough that works. When I implemented it into my code when accessing a method, I

Preprocessor : Get Operating System .Net Core

不羁的心 提交于 2021-02-09 15:13:41
问题 I'm writing a class that I wish to use on both Windows & Linux. One of the methods that is in this class is accessing the Windows Registry What I'm hoping to achieve is to somehow disable this particular method from being used when using a Linux machine. First of all I did some research to see if there was something for .Net Core that would allow me to check which operating system is in use, I found this and sure enough that works. When I implemented it into my code when accessing a method, I

Dependency injection between two ASP.NET Core projects

痴心易碎 提交于 2021-02-09 12:46:16
问题 I'm currently developing a web application with ASP.NET Core and handling the database with Entity Framework Core. I have two projects in my VS Solution; WebApp (the main application) and DatabaseHandler (the EF Core handler). I have installed Entity Framework Core with the Pomelo package, since I'm using a MySQL database. I've been following the Microsoft documentation to setup EF Core, connection strings and all that, and it works fine. I'm able to make migrations, make updates and do stuff

Dependency injection between two ASP.NET Core projects

偶尔善良 提交于 2021-02-09 12:45:18
问题 I'm currently developing a web application with ASP.NET Core and handling the database with Entity Framework Core. I have two projects in my VS Solution; WebApp (the main application) and DatabaseHandler (the EF Core handler). I have installed Entity Framework Core with the Pomelo package, since I'm using a MySQL database. I've been following the Microsoft documentation to setup EF Core, connection strings and all that, and it works fine. I'm able to make migrations, make updates and do stuff

Configure JWT Bearer token validation using the public security key in .NET Core

隐身守侯 提交于 2021-02-09 10:57:21
问题 My web application is a kind of wrapper for some 3rd party service. This 3rd party service uses the JWT Bearer authentication to access its WebAPI endpoints. The tokens are encrypted with RS256 algorithm (asymmetric). I have a Public Key to validate tokens signature on my side. It is easy to validate signature on jwt.io site (just paste the token and public key to the text boxes). But how do I configure TokenValidationParameters to have tokens validated automatically using specified Public