Skip to content

Daniel15/SimpleIdentity

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

ASP.NET SimpleIdentity

A simple ASP.NET Core authentication and identity provider, ideal for smaller websites. Valid users are specified in a simple configuration file rather than a database.

Bug reports and feature requests are welcome!

Installation

If you are creating a brand new ASP.NET Core web application, ensure you select "No Authentication" when creating it.

Install NuGet package:

Install-Package Daniel15.SimpleIdentity

Create configuration. SimpleIdentity uses the standard ASP.NET configuration library. Running Daniel15.SimpleIdentity.Setup will allow you to enter a email address and password, and output the required config section. An example using user@example.com as the email address and password as the password:

    "Auth": {
        "Users": {
            "USER@EXAMPLE.COM": {
                "Email": "user@example.com",
                "NormalizedUserName": "USER@EXAMPLE.COM",
                "PasswordHash": "AQAAAAEAACcQAAAAEJOYL0MGZ5CNnERvqzI2Wl9eJLXMsuchKP1EIWGQneZ1GuNCjheC4pD1AWgVy+decQ=="
            }
        }
    }

Place this in any config file (for example, config.json). In a production scenario, you will want to store this in a separate config file that's not checked in to source control.

Configure SimpleIdentity in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    // Add Identity services to the services container.
    services.AddIdentity<SimpleIdentityUser, SimpleIdentityRole>()
        .AddSimpleIdentity<SimpleIdentityUser>(Configuration.GetConfigurationSection("Auth"))
        .AddDefaultTokenProviders();

Enable identity services by adding this before app.UseMvc:

// Add cookie-based authentication to the request pipeline.
app.UseAuthentication();

Create login form. Some example files are included, based off the regular ASP.NET authentication:

Hit /Account/Login and it should work :)

For a full example, see the included sample project.

Changelog

2.0.0 - 17th October 2017

  • Upgrade to ASP.NET Core 2.0
  • Throw better error message when config is missing

1.2.0 - 21st August 2016

  • Upgrade to ASP.NET Core RTM

1.1.0 - 27th May 2016

  • Upgrade to ASP.NET Core RC 2

1.0.1 - 20th November 2015

  • Upgrade to ASP.NET 5 RC 1

1.0 - 8th August 2015

  • Initial release

About

Simple ASP.NET Core authentication and identity provider. Valid users are specified in a simple configuration file.

Resources

License

Stars

Watchers

Forks

Packages

No packages published