Nudes.Identity is an ASP.Net Core Library to include all basic OAuth2 + OpenIdConnect basic functionality such as:
- Authorization Code Flow
- Consent Grant
- Consent Management
- Device Management
//TODO:Add influences
Use the package manager nuget to install Nudes.Identity
PM> Install-Package {//TODO:}
or
> dotnet add package {//TODO:}
To use Nudes.Identity
will need to also use IdentityServer4
and MediatR
First you need to setup your identity server configuration
On ConfigureServices
at Startup.cs
services.AddIdentityServer()
.YourSpecificProjectConfigurations();
On Configure
at Startup.cs
app.UseIdentityServer();
On ConfigureServices
at Startup.cs
services.AddControllerWithViews()
.AddNudesIdentity();
All Nudes.Identity pages work based on cookie authentication using "Nudes.Identity"
schema so we gotta set it up
On ConfigureServices
at Startup.cs
using Nudes.Identity.Options;
//..//
services.AddAuthentication("Bearer") //or your specific authentication schema
.AddCookie(NudesIdentityOptions.NudesIdentitySchema)
.AddJwtBearer(op => /*...*/ ); //with your custom configuration
It must be after
app.UseIdentityServer()
On Configure
at Startup.cs
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
if you are not familiar with MediatR
you can read all about it here
this handler will be used by the authorization logic to decide if it should authenticate an user or not, so you must implement your user data getting and password validation here
On any file
public class ValidateUserCredentialsHandler : IRequestHandler<ValidateUserCredentialsQuery, UserResult>
{
public Task<UserResult> Handle(ValidateUserCredentialsQuery request, CancellationToken cancellationToken)
{
if (request.Username == "bob" && request.Password == "bob")
{
return Task.FromResult(new UserResult()
{
Username = "bob",
SubjectId = "1",
});
}
return Task.FromResult<UserResult>(null);
}
}
On ConfigureServices
at Startup.cs
using MediatR;
services.AddMediatR(this.GetType().Assembly);
//TODO:
These are the following views that are avaiable
- Account/Login
- Account/Logout
- Consent
- Device
- Device/UserCodeCapture
- Device/Callback
- Grants
- Grants/Revoke
- Home
- Home/Error
- External/Challenge
- External/Callback