DiyAuth 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package DiyAuth --version 1.0.5
NuGet\Install-Package DiyAuth -Version 1.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DiyAuth" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DiyAuth --version 1.0.5
#r "nuget: DiyAuth, 1.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DiyAuth as a Cake Addin
#addin nuget:?package=DiyAuth&version=1.0.5

// Install DiyAuth as a Cake Tool
#tool nuget:?package=DiyAuth&version=1.0.5

DiyAuth

Nuget Link

What is DiyAuth?

DIY Auth is a project aimed at placing the control and responsibility of user authentication in your hands. It implements a simple authorization and authentication scheme following industry best practices that is plug-and-play to help you jump start your next project. Furthermore it stores your user's authentication data in your cloud instance, allowing you to be free of relying on third party services to manage your data.

Why is there a need for it?

Everytime I want to start a new side project I invariably have to rebuild the ability to allow users to login. In the past I've used services like Parse (RIP) to do the authentication for me but relying on a centralized third-party service to accomplish your authentication and authorization isn't the best because:

  • The service can shut down (Like Parse did) leaving you without a way to authenticate
  • It can be a bottleneck in your system that you can't control

It's a decent time sink everytime I have to build it and I'd rather just get to building the meat and potatoes of the idea than building the authentication mechanism everytime. I feel like other developers have the same issue so I decided to build this into an open source library that implements the most common functionality as far as user authentication and authorization goes.

Things that you must handle

DiyAuth can handle a lot of the background encrypting and management for you but you must make sure the following things are taken care of:

  • You must use HTTPS to ensure the email address and password are secure until they make their way into your application's endpoint
  • Do not log the password anywhere at any point

Recommendations on data layout

The authorization/authentication endpoints in the project return an IdentityId Guid. I would take those and use them in your own databases to store other user related data keyed by this IdentityId e.g. Usernames, Address etc.

How do I use it?

First and foremost there is a sample UWP application that uses the DiyAuth project included in the repository in the SampleApp folder. To use the DiyAuth in it's simplest configuration using an Azure Storage Account as your backend, all you have to do is initialize it as such:

var authenticationProvider = await Authenticator.GetAzureAuthenticator(storageAccountConnectionString)

I recommend caching the authentication provider somewhere as all other methods are exposed off of it.

Standard use cases

The following methods are exposed off of the authentication provider (and are listed in the IAuthenticationProvider)

  • CheckIdentityExists(string emailAddress): You probably want to check if an identity exists before attempting to create it.

  • CreateIdentity(string emailAddress, string password): Before being able to authorize or authenticate, you have to create an identity.

  • Authorize(string emailAddress, string password): Once an identity has been created, you can authorize it and get an authentication Token that can be used to authenticate and retrieve an IdentityId.

  • Authenticate(string token): You can use the authentication Token and use the Authenticate method to retrieve an IdentityId.

  • ChangePassword(string emailAddress, string oldPassword, string newPassword): Allows a user to change their password by providing their old password.

  • GenerateTokenForIdentityId(Guid identityId): Allows for the ability to possibly impersonate any identity in the system.

  • DeleteToken(string token): Delete a token, which invalidates it and does not let it past the Authenticate method.

  • DeleteIdentity(Guid identityId): Deletes the identity associated with the provided IdentityId as well as all Tokens associated with said IdentityId.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7.4 698 12/29/2019
1.0.7.3 515 12/29/2019
1.0.7.2 599 9/9/2019
1.0.6 544 9/7/2019
1.0.5 554 7/22/2019
1.0.4 567 5/13/2019
1.0.3 578 3/9/2019
1.0.2 590 3/6/2019
1.0.1 814 3/4/2019
1.0.0 909 3/4/2019