Versatile OpenID Connect stack for ASP.NET Core and Microsoft.Owin (compatible with ASP.NET 4.6.1)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Bart Calixto 2c72d586ed Update the Mvc.Client/Mvc.Server samples to use HttpPlatformHandler 10 years ago
samples Update the Mvc.Client/Mvc.Server samples to use HttpPlatformHandler 10 years ago
src React to recent changes in aspnet/DependencyInjection 10 years ago
.gitattributes Set up the initial project structure 10 years ago
.gitignore Set up the initial project structure 10 years ago
.travis.yml Set up the initial project structure 10 years ago
LICENSE.md Add LICENSE.md 10 years ago
NuGet.config Update build.cmd and build.sh to use NuGet's latest version 10 years ago
OpenIddict.sln Decouple MVC from the core project and introduce OpenIddict modules support 10 years ago
README.md Update README.md 10 years ago
build.cmd Update build.cmd and build.sh to use NuGet's latest version 10 years ago
build.sh Update build.cmd and build.sh to use NuGet's latest version 10 years ago
global.json Set up the initial project structure 10 years ago
makefile.shade Set up the initial project structure 10 years ago

README.md

OpenIddict

The OpenID Connect server you'll be addicted to.

Build status Build status

What's OpenIddict?

OpenIddict aims at providing a simple and easy-to-use solution to implement an OpenID Connect server in any ASP.NET 5 application.

Why an OpenID Connect server?

Adding an OpenID Connect server to your application allows you to support token authentication. It also allows you to manage all your users using local password or an external identity provider (e.g. Facebook or Google) for all your applications in one central place, with the power to control who can access your API and the information that is exposed to each client.

How does it work?

OpenIddict is based on ASP.NET Identity 3 (for user management) and relies on AspNet.Security.OpenIdConnect.Server to control the OpenID Connect authentication flow. It comes with a built-in MVC 6 controller and native views that you can easily replace by your own ones to fully customize your login experience:

OpenIddict fully supports the code/implicit/hybrid flows and the client credentials/resource owner password grants. For more information about these terms, please visit the OpenID website and read the OAuth2 specification.

Note: OpenIddict uses EntityFramework 7 by default, but you can also provide your own store.


Getting started

To use OpenIddict, you need to:

  • Have an existing project or create a new one (note: when creating a new project using Visual Studio's default ASP.NET 5 template, using individual user accounts authentication is strongly recommended).

  • Add the appropriate MyGet repositories to your NuGet sources. This can be done by adding a new NuGet.Config file at the root of your solution:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="aspnet-contrib" value="https://www.myget.org/F/aspnet-contrib/api/v2" />
    <add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" />
    <add key="AzureAd Nightly" value="http://www.myget.org/F/azureadwebstacknightly/" />
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>
  • Update your project.json to import the OpenIddict package:
"dependencies": {
    "OpenIddict": "1.0.0-*"
},
  • Configure the OpenIddict services in Startup.ConfigureServices:
public void ConfigureServices(IServiceCollection services) {
    services.AddMvc();

    services.AddEntityFramework()
        .AddSqlServer()
        .AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

    services.AddIdentity<ApplicationUser, IdentityRole>()
        .AddEntityFrameworkStores<ApplicationDbContext>()
        .AddDefaultTokenProviders()
        .AddOpenIddict(); // Add the OpenIddict services after registering the Identity services.
}
  • Add the OpenIddict middleware in your ASP.NET 5 pipeline by calling app.UseOpenIddict() after app.UseIdentity():
public void Configure(IApplicationBuilder app) {
    app.UseIdentity();
    
    // Add all the external providers you need before registering OpenIddict:
    app.UseGoogleAuthentication();
    app.UseFacebookAuthentication();
    
    app.UseOpenIddict();
}

Note: UseOpenIddict() must be registered after app.UseIdentity() and the external providers.

For a better insight on the different options and configurations available, check out Configuration and Options in the project wiki.

Support

Need help or wanna share your thoughts? Don't hesitate to join our dedicated chat rooms:

Contributors

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