All Projects β†’ aloji β†’ Jwtsecurity

aloji / Jwtsecurity

JWT Server for Asp.Net Core and Asp.Net WebAPI2

Projects that are alternatives of or similar to Jwtsecurity

SignalR-Core-SqlTableDependency
Shows how the new SignalR Core works with hubs and sockets, also how it can integrate with SqlTableDependency API.
Stars: ✭ 36 (+125%)
Mutual labels:  aspnetcore, asp-net-core, netcore2
Jpproject.identityserver4.adminui
πŸ”§ ASP.NET Core 3 & Angular 8 Administration Panel for πŸ’žIdentityServer4 and ASP.NET Core Identity
Stars: ✭ 717 (+4381.25%)
Mutual labels:  asp-net-core, aspnetcore, oauth2
JwtAuthDemo
ASP.NET Core + Angular JWT auth demo; integration tests; login, logout, refresh token, impersonation, authentication, authorization; run on Docker Compose.
Stars: ✭ 278 (+1637.5%)
Mutual labels:  aspnetcore, jwt-token, asp-net-core
Equinoxproject
Full ASP.NET Core 5 application with DDD, CQRS and Event Sourcing concepts
Stars: ✭ 5,120 (+31900%)
Mutual labels:  asp-net-core, aspnetcore
Jose Jwt
Ultimate Javascript Object Signing and Encryption (JOSE) and JSON Web Token (JWT) Implementation for .NET and .NET Core
Stars: ✭ 692 (+4225%)
Mutual labels:  oauth2, jwt-token
Epplus.core
EPPlus.Core is an unofficial port of the EPPlus library to .NET Core
Stars: ✭ 354 (+2112.5%)
Mutual labels:  asp-net-core, aspnetcore
Jpproject.identityserver4.sso
πŸ”’ ASP.NET Core 3.1 Open Source SSO. Built within IdentityServer4 πŸ”‘
Stars: ✭ 298 (+1762.5%)
Mutual labels:  asp-net-core, oauth2
Sieve
βš—οΈ Clean & extensible Sorting, Filtering, and Pagination for ASP.NET Core
Stars: ✭ 560 (+3400%)
Mutual labels:  aspnetcore, netcore2
Aspnet.security.openidconnect.server
OpenID Connect/OAuth2 server framework for OWIN/Katana and ASP.NET Core
Stars: ✭ 544 (+3300%)
Mutual labels:  aspnetcore, oauth2
Asp.net Core Template
A ready-to-use template for ASP.NET Core with repositories, services, models mapping, DI and StyleCop warnings fixed.
Stars: ✭ 599 (+3643.75%)
Mutual labels:  asp-net-core, aspnetcore
Auth Service
spring security + oauth2.0 + jwt
Stars: ✭ 622 (+3787.5%)
Mutual labels:  oauth2, jwt-token
Practical Aspnetcore
Practical samples of ASP.NET Core 2.1, 2.2, 3.1, 5.0 and 6.0 projects you can use. Readme contains explanations on all projects.
Stars: ✭ 6,199 (+38643.75%)
Mutual labels:  asp-net-core, aspnetcore
Itextsharp.lgplv2.core
iTextSharp.LGPLv2.Core is an unofficial port of the last LGPL version of the iTextSharp (V4.1.6) to .NET Core
Stars: ✭ 322 (+1912.5%)
Mutual labels:  asp-net-core, aspnetcore
Aspnetcore Webapi Sample
This is a sample ASP.NET Core WebAPI
Stars: ✭ 310 (+1837.5%)
Mutual labels:  asp-net-core, aspnetcore
Netcorebbs
ASP.NET Core Light forum NETCoreBBS
Stars: ✭ 483 (+2918.75%)
Mutual labels:  asp-net-core, aspnetcore
Simplcommerce
A simple, cross platform, modularized ecommerce system built on .NET Core
Stars: ✭ 3,474 (+21612.5%)
Mutual labels:  asp-net-core, aspnetcore
Awesome Blazor
Resources for Blazor, a .NET web framework using C#/Razor and HTML that runs in the browser with WebAssembly.
Stars: ✭ 6,063 (+37793.75%)
Mutual labels:  asp-net-core, aspnetcore
Nopcommerce
The most popular open-source eCommerce shopping cart solution based on ASP.NET Core
Stars: ✭ 6,827 (+42568.75%)
Mutual labels:  asp-net-core, aspnetcore
Angularaspnetcoreoauth
Sample project demonstrating user authentication and identity with Angular, Asp.Net Core and IdentityServer4
Stars: ✭ 268 (+1575%)
Mutual labels:  aspnetcore, oauth2
Live.asp.net
Code for live.asp.net, which hosts the ASP.NET Community Stand-up
Stars: ✭ 295 (+1743.75%)
Mutual labels:  asp-net-core, aspnetcore

Build status

JwtSecurity

The object is to allow using a token generated in an OWIN OAuth 2.0 Server in AspNet.Core projects.

Nugets: https://www.nuget.org/profiles/aloji

Real life problem

We have the authorization server implemented with OWIN OAuth 2.0, but the new developments are with AspNetCore

The first idea was to use the machine keys

MachineKey

If the authorization server and the resource server are not on the same computer, the OAuth middleware will use the different machine keys to encrypt and decrypt bearer access token. In order to share the same private key between both projects, we add the same machinekey setting in both web.config files.

The problem is that machinekey does not exist in AspNetCore, but MS gives us a compatibility solution to replace the machinekey settings in AspNetWebApi2 and using a key storge provider like redis we can be shared the keys.

After several hours trying to implement this solution, I realized that it was easier, cleaner and cheaper to change the token generator to use JWT and dont use any external provider.

Configuration

How to setup the JwtSecurity in OWIN OAuth 2.0 Server (full sample code)

public class Startup
{
    public void Configuration(IAppBuilder appBuilder)
    {
        appBuilder.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions
        {
            AccessTokenFormat = new JwtSecureDataFormat(
                new JwtSecurityOptions
                {
                    Issuer = "yourIssuerCode",
                    IssuerSigningKey = "yourIssuerSigningKeyCode"
                })
        });
    }
}

How to setup the JwtSecurity in Resource Server .NetFramework (full sample code)

public class Startup
{
    public void Configuration(IAppBuilder appBuilder)
    {
        appBuilder.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
        {
            AccessTokenFormat = new JwtSecureDataFormat(
                new JwtSecurityOptions
                {
                    Issuer = "yourIssuerCode",
                    IssuerSigningKey = "yourIssuerSigningKeyCode"
                })
        });
    }
}

How to setup the JwtSecurity in Resource Server .NetFramework with Owin Auth Compatibility

public class Startup
{
    public void Configuration(IAppBuilder appBuilder)
    {
        appBuilder.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
        {
            AccessTokenFormat = new MachineKeyCompatibilityDataFormat(
                new JwtSecurityOptions
                {
                    Issuer = "yourIssuerCode",
                    IssuerSigningKey = "yourIssuerSigningKeyCode"
                })
        });
    }
}

How to setup the JwtSecurity in Resource Server .NetCore (full sample code)

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services
              .AddJwtBearerAuthentication(options =>
              {
                  options.Issuer = "yourIssuerCode";
                  options.IssuerSigningKey = "yourIssuerSigningKeyCode";
              });
    }
    
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
          app.UseAuthentication();
    }
}

Bonus:

I developed a middleware to create a JwtServer with AspNetCore very similar to OwinOAuth2 settings

How to setup the JwtServer in AspNetCore (full sample code)

 public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddJwtServer();
    }
    
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
          app.UseJwtServer(options => {
                options.TokenEndpointPath = "/token";
                options.AccessTokenExpireTimeSpan = new TimeSpan(1, 0, 0);
                options.Issuer = "yourIssuerCode";
                options.IssuerSigningKey = "yourIssuerSigningKeyCode";
                options.AuthorizationServerProvider = new AuthorizationServerProvider
                {
                    OnGrantResourceOwnerCredentialsAsync = async (context) =>
                    {
                        if (context.UserName != context.Password)
                        {
                            context.SetError("Invalid user authentication");
                            return;
                        }

                        var claims = new List<Claim>
                        {
                            new Claim(ClaimTypes.Surname, context.UserName)
                        };

                        context.Validated(claims);
                        await Task.FromResult(0);
                    }
                };
            });
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].