All Projects → aspnet-contrib → Aspnet.security.openidconnect.server

aspnet-contrib / Aspnet.security.openidconnect.server

OpenID Connect/OAuth2 server framework for OWIN/Katana and ASP.NET Core

Projects that are alternatives of or similar to Aspnet.security.openidconnect.server

Openiddict Samples
ASP.NET Core, Microsoft.Owin/ASP.NET 4.x and JavaScript samples for OpenIddict
Stars: ✭ 214 (-60.66%)
Mutual labels:  aspnetcore, oauth2, openidconnect
Openiddict Core
Versatile OpenID Connect stack for ASP.NET Core and Microsoft.Owin (compatible with ASP.NET 4.6.1)
Stars: ✭ 2,275 (+318.2%)
Mutual labels:  aspnetcore, oauth2, openidconnect
Jpproject.identityserver4.adminui
🔧 ASP.NET Core 3 & Angular 8 Administration Panel for 💞IdentityServer4 and ASP.NET Core Identity
Stars: ✭ 717 (+31.8%)
Mutual labels:  aspnetcore, oauth2
Jwtsecurity
JWT Server for Asp.Net Core and Asp.Net WebAPI2
Stars: ✭ 16 (-97.06%)
Mutual labels:  aspnetcore, oauth2
Samples.aspnetcore Identityserver4
IdentityServer4 sample with .NET Core and ASP.NET Core 2.0
Stars: ✭ 115 (-78.86%)
Mutual labels:  aspnetcore, oauth2
Jose2go
Golang (GO) implementation of Javascript Object Signing and Encryption specification
Stars: ✭ 150 (-72.43%)
Mutual labels:  oauth2, openidconnect
Aspnet5identityserverangularimplicitflow
OpenID Connect Code / Implicit Flow with Angular and ASP.NET Core 5 IdentityServer4
Stars: ✭ 670 (+23.16%)
Mutual labels:  aspnetcore, oauth2
Aspnet.security.oauth.providers
OAuth 2.0 social authentication providers for ASP.NET Core
Stars: ✭ 1,186 (+118.01%)
Mutual labels:  aspnetcore, oauth2
Login Cidadao
Projeto Login Cidadão
Stars: ✭ 61 (-88.79%)
Mutual labels:  oauth2, openidconnect
Aspnetcoreangularsignalrsecurity
Security with ASP.NET Core, SignalR and Angular
Stars: ✭ 171 (-68.57%)
Mutual labels:  aspnetcore, oauth2
openiddict-documentation
OpenIddict documentation
Stars: ✭ 53 (-90.26%)
Mutual labels:  aspnetcore, openidconnect
Nginx Openid Connect
Reference implementation of OpenID Connect integration for NGINX Plus
Stars: ✭ 96 (-82.35%)
Mutual labels:  oauth2, openidconnect
Oauth2 Oidc Debugger
An OAuth2 and OpenID Connect Debugger
Stars: ✭ 78 (-85.66%)
Mutual labels:  oauth2, openidconnect
Auth
:atom: Social (OAuth1\OAuth2\OpenID\OpenIDConnect) sign with PHP
Stars: ✭ 457 (-15.99%)
Mutual labels:  oauth2, openidconnect
Cas
Apereo CAS - Enterprise Single Sign On for all earthlings and beyond.
Stars: ✭ 9,154 (+1582.72%)
Mutual labels:  oauth2, openidconnect
Identityserver4 Swagger Integration
How to get Swashbuckle or NSwag Swagger UI's working with IdentityServer 4
Stars: ✭ 60 (-88.97%)
Mutual labels:  aspnetcore, oauth2
Lua Resty Openidc
OpenID Connect Relying Party and OAuth 2.0 Resource Server implementation in Lua for NGINX / OpenResty
Stars: ✭ 626 (+15.07%)
Mutual labels:  oauth2, openidconnect
Jose Jwt
Ultimate Javascript Object Signing and Encryption (JOSE) and JSON Web Token (JWT) Implementation for .NET and .NET Core
Stars: ✭ 692 (+27.21%)
Mutual labels:  oauth2, openidconnect
Angularaspnetcoreoauth
Sample project demonstrating user authentication and identity with Angular, Asp.Net Core and IdentityServer4
Stars: ✭ 268 (-50.74%)
Mutual labels:  aspnetcore, oauth2
fastapi-azure-auth
Easy and secure implementation of Azure AD for your FastAPI APIs 🔒 B2C, single- and multi-tenant support.
Stars: ✭ 174 (-68.01%)
Mutual labels:  oauth2, openidconnect

AspNet.Security.OpenIdConnect.Server

⚠️ This project has been merged into OpenIddict. For more information, read Introducing OpenIddict 3.0 beta1.

AspNet.Security.OpenIdConnect.Server is an advanced OAuth2/OpenID Connect server framework for both ASP.NET Core 1.x/2.x and OWIN/Katana 3.x/4.x, designed to offer a low-level, protocol-first approach.

The latest official release can be found on NuGet and the nightly builds on MyGet.

Build status Build status

Get started

Based on OAuthAuthorizationServerMiddleware from Katana, AspNet.Security.OpenIdConnect.Server exposes similar primitives and can be directly registered in Startup.cs using the UseOpenIdConnectServer extension method:

public void ConfigureServices(IServiceCollection services)
{
    services.AddAuthentication().AddOpenIdConnectServer(options =>
    {
        // Enable the token endpoint.
        options.TokenEndpointPath = "/connect/token";
    
        // Implement OnValidateTokenRequest to support flows using the token endpoint.
        options.Provider.OnValidateTokenRequest = context =>
        {
            // Reject token requests that don't use grant_type=password or grant_type=refresh_token.
            if (!context.Request.IsPasswordGrantType() && !context.Request.IsRefreshTokenGrantType())
            {
                context.Reject(
                    error: OpenIdConnectConstants.Errors.UnsupportedGrantType,
                    description: "Only grant_type=password and refresh_token " +
                                 "requests are accepted by this server.");
    
                return Task.CompletedTask;
            }
    
            // Note: you can skip the request validation when the client_id
            // parameter is missing to support unauthenticated token requests.
            // if (string.IsNullOrEmpty(context.ClientId))
            // {
            //     context.Skip();
            // 
            //     return Task.CompletedTask;
            // }
    
            // Note: to mitigate brute force attacks, you SHOULD strongly consider applying
            // a key derivation function like PBKDF2 to slow down the secret validation process.
            // You SHOULD also consider using a time-constant comparer to prevent timing attacks.
            if (string.Equals(context.ClientId, "client_id", StringComparison.Ordinal) &&
                string.Equals(context.ClientSecret, "client_secret", StringComparison.Ordinal))
            {
                context.Validate();
            }
    
            // Note: if Validate() is not explicitly called,
            // the request is automatically rejected.
            return Task.CompletedTask;
        };
    
        // Implement OnHandleTokenRequest to support token requests.
        options.Provider.OnHandleTokenRequest = context =>
        {
            // Only handle grant_type=password token requests and let
            // the OpenID Connect server handle the other grant types.
            if (context.Request.IsPasswordGrantType())
            {
                // Implement context.Request.Username/context.Request.Password validation here.
                // Note: you can call context Reject() to indicate that authentication failed.
                // Using password derivation and time-constant comparer is STRONGLY recommended.
                if (!string.Equals(context.Request.Username, "Bob", StringComparison.Ordinal) ||
                    !string.Equals(context.Request.Password, "[email protected]", StringComparison.Ordinal))
                {
                    context.Reject(
                        error: OpenIdConnectConstants.Errors.InvalidGrant,
                        description: "Invalid user credentials.");
    
                    return Task.CompletedTask;
                }
    
                var identity = new ClaimsIdentity(context.Scheme.Name,
                    OpenIdConnectConstants.Claims.Name,
                    OpenIdConnectConstants.Claims.Role);
    
                // Add the mandatory subject/user identifier claim.
                identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "[unique id]");
    
                // By default, claims are not serialized in the access/identity tokens.
                // Use the overload taking a "destinations" parameter to make sure
                // your claims are correctly inserted in the appropriate tokens.
                identity.AddClaim("urn:customclaim", "value",
                    OpenIdConnectConstants.Destinations.AccessToken,
                    OpenIdConnectConstants.Destinations.IdentityToken);
    
                var ticket = new AuthenticationTicket(
                    new ClaimsPrincipal(identity),
                    new AuthenticationProperties(),
                    context.Scheme.Name);
    
                // Call SetScopes with the list of scopes you want to grant
                // (specify offline_access to issue a refresh token).
                ticket.SetScopes(
                    OpenIdConnectConstants.Scopes.Profile,
                    OpenIdConnectConstants.Scopes.OfflineAccess);
    
                context.Validate(ticket);
            }
    
            return Task.CompletedTask;
        };
    });
}

Note: in order for the OpenID Connect server to work properly, the authentication middleware must be registered in the ASP.NET Core 2.0 pipeline:

public void Configure(IApplicationBuilder app)
{
    app.UseAuthentication();
}

Note: the AspNet.Security.OpenIdConnect.Server 2.x packages are only compatible with ASP.NET Core 2.x. If your application targets ASP.NET Core 1.x, use the AspNet.Security.OpenIdConnect.Server 1.x packages.

Resources

Looking for additional resources to help you get started? Don't miss these interesting blog posts:

Samples

The samples found in the current project directory always target the latest ASP.NET Core releases and are mainly meant to ease its testing.

Official samples targetting ASP.NET Core can be found on aspnet-contrib/AspNet.Security.OpenIdConnect.Samples.

Looking for something simpler? Don't miss OpenIddict, the simple and easy-to-use OpenID Connect server for ASP.NET Core 1.x and 2.0 based on AspNet.Security.OpenIdConnect.Server.

Support

Need help or wanna share your thoughts? Don't hesitate to join us on Gitter or ask your question on StackOverflow:

Contributors

AspNet.Security.OpenIdConnect.Server is actively maintained by Kévin Chalet. Contributions are welcome and can be submitted using pull requests.

License

This project is licensed under the Apache License. This means that you can use, modify and distribute it freely. See http://www.apache.org/licenses/LICENSE-2.0.html for more details.

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].