
Master asp.net core identity with mvc by exploring authentication and authorization, roles, claims, policies, and robust login workflows from setup to advanced concepts.
Discover how ASP.NET Core Identity serves as a flexible user store with password hashing, token generation, and multi-factor authentication for MVC apps, while clarifying its role separate from authentication middleware.
Demonstrates an ASP.NET Core Identity app with login, social login, role and claim management, and policies, clarifying that the course focuses on security, not dynamic access to pages.
Authentication verifies who you are using a username, password, and claims, while authorization determines what access you have.
Compare cookie based and token based authentication, noting cookie based is stateful with server session tracking, while token based uses JWT and remains stateless for external logins.
Compare cookie-based and token-based authentication flows. Cookie flow creates a server-side session and cookie, while token flow returns a JWT stored client-side and sent in an authorization header.
Explore how asp.net core identity uses a store and role store as a data access layer with interfaces, and how user manager, role manager, and the sign-in manager extend authentication.
Explore how role-based authorization and claims in asp.net core identity control access in mvc apps, with examples like admin, manager, front desk roles, and elite customer claims.
Discover the essential tools for this course by installing Visual Studio 2022 and SQL Server, the only tools required for mastering ASP.NET Core Identity in MVC.
Access project resources for the identity management course, including the GitHub code and commit history, and download the course content with Identity Manager snippets and PowerPoint slides.
Open Visual Studio 2022 to create a new MVC app template, name Identity Manager, place project in same directory, use dotnet eight, and start fresh with none for authentication.
Run the mvc project to view the home and privacy pages. Add dotnet identity via two options: during project creation or after configuring the DbContext to enable authentication and authorization.
Configure Entity Framework Core authentication by adding a database connection string in appsettings.json, including server name, identity manager database, trusted_connection, and active result sets, then install NuGet packages.
Configure Entity Framework Core by creating application DbContext, installing SQL Server and Entity Framework Core packages, and set up Identity using IdentityDbContext for authentication and authorization with code-first data access.
Configure the identity db context by wiring db context options to the identity base class and register it in program.cs using a sql server connection string from appsettings.json.
Learn to create and migrate the database for ASP.NET Core Identity by using the package manager console to add a migration, install EF Core tools, and update the database.
Add identity service to the mvc app using add identity, connect identity with the application db context via entity framework stores, and ensure authentication runs before authorization.
Extend the default ASP.NET identity user with an application user class, add properties like name, configure a dbset in the context, and run migrations to add new columns.
Create login and register pages by building login and register view models with data annotations for email, password, remember me, name, and confirm password, then scaffold controller and views.
Create a register view and its view model inside an account controller, wire a register post endpoint, and enable client-side validation with Razor and asp-for tag helpers.
Create an underscore login partial view in the shared folder to render login and register links in the navbar, and include it in the main layout with a partial tag.
Register the first user using ASP.NET Core Identity with automatic password hashing via user manager and sign in manager, leveraging dependency injection and anti-forgery validation.
Register users and observe the discriminator column indicating identity user versus application user. Change program.cs to use application user, and inject user manager and sign in manager for registration.
Handle errors by adding identity result errors to the model state, displaying messages for issues like username already taken and a six-character password.
Inject sign in manager and user manager into the view to detect a signed-in user, display their email, and provide a logout option using ASP.NET Core Identity.
Create a post action named log off in the account controller, protected by an anti-forgery token, and sign out with sign in manager's SignOutAsync, then redirect to the home index.
Create the login view in ASP.NET Core Identity MVC, wire it to the account controller, and scaffold a Razor login view with remember me and register links.
Implement the login post endpoint using signInManager.PasswordSignInAsync to authenticate with email and password after validating the model state; on success, redirect to home, on failure, show an invalid login attempt.
Implement return URL handling in ASP.NET Core Identity by using an authorized action, capturing the return URL in login, and performing a local redirect back to the original page.
Explore how ASP.NET Core Identity MVC enforces and customizes the default password requirements, including lockout settings, by configuring identity options such as minimum length, require digit, lowercase, and non-alphanumeric.
Shows lockout in ASP.NET Core Identity, setting max failed attempts to three, tracking failed counts, and unlocking by clearing the lockout end date, with a lockout view.
Implement a forgot password flow in asp.net core identity mvc by creating the forgot password view and email-only view model, plus get and post endpoints in the account controller.
Learn how to implement password reset emails in an ASP.NET Core Identity MVC app using SendGrid, including setting up a domain-verified sender and integrating the SendGrid NuGet package.
Learn to implement a custom email sender for ASP.NET Core Identity in MVC, using SendGrid with dependency injection and reading the SendGrid key from appsettings, and register it in Program.cs.
Implement a secure forgot password flow by sending a confirmation email, injecting an email sender, generating a reset token, and validating the code via a reset password endpoint.
Create a reset password view model with password, confirm password, email, and code; implement a post endpoint with anti-forgery protection and design reset password and confirmation views.
Design a reset password view in Razor, reuse the register view, include password and confirm password, remove name and return url, post to reset password, and add a login link.
Reset the password through the post endpoint by validating model, retrieving the user by email with the user manager, and resetting with a token and new password; redirect on success.
Learn to implement email confirmation in ASP.NET Core Identity by generating a confirmation token, sending a confirm email with a callback URL, and updating the email confirmed status on signup.
Validate the token and confirm the user's email using the user manager, retrieving the user by id and directing to success or error views in ASP.NET Core Identity MVC.
Implement an enable authenticator get endpoint that generates a new authenticator key, builds a two factor authentication view model with a token, and returns it to the authorized user.
Create the enable authenticator view for two-factor authentication, reusing the register view structure, with a post endpoint, code input, and a conditional home link based on user authentication.
Enable authenticator post login demonstrates pairing a secret with Google or Microsoft authenticator to generate time-based codes and complete two-factor authentication via a post endpoint.
Set up two factor authentication in ASP.NET Core Identity using an authenticator app, with a manual secret key when no qr code is available, and verify the token.
Set up a two factor authentication flow by adding a verify authenticator code GET endpoint and a verify authenticator view model with code, return URL, and remember me.
Build a verify authenticator view and its view model to enter the Microsoft Authenticator code, handle the return URL, and post to an endpoint that signs in.
Implement a post endpoint to verify authenticator codes, apply anti-forgery validation, and use two-factor authenticator sign-in to secure login flows with a return URL and remember options.
Describes resetting the authenticator key in ASP.NET Core Identity, how login with a code can fail, and why production should avoid this by ensuring two-factor is properly managed.
Implement two-factor authentication by integrating a qr code generator and authenticator uri in an mvc app, using a JavaScript qr code file and encoding issuer and email into the url.
Learn to manage two factor authentication in ASP.NET Core Identity MVC by adding a remove authenticator option and toggling two factor status on the index view.
Add an http get endpoint remove authenticator in the account controller to reset the authenticator key, clear two factor enabled, and redirect to home, then test by logging in again.
Explore basic authorization using the authorize attribute to restrict access to actions like privacy, and learn how allow anonymous on login and register prevents redirect loops.
Check for existing roles in the ASP.NET Core Identity, then create admin and user roles using the role manager with create async, ensuring proper role mapping for users.
Add a roles dropdown to the register page by updating the register view model with a roles list and a selected role, and populate the UI accordingly.
Fetch dynamic roles via role manager, project role names to select list items with Entity Framework Core, and repopulate the dropdown on model state errors for the register view.
Assigns the selected role to a new user during registration using the user manager and AddToRoleAsync for a role, updating the role mapping table and enabling home page role display.
Configure application cookies to control access by role, override the access denied path, and route users to a custom no access page when unauthorized.
Create a new user controller to list all users, injecting the application db context and user manager, and populate each user’s role from the mappings.
Create an index view that displays a Bootstrap table of application users with email, name, and role, using an enumerable model and a foreach loop in ASP.NET Core Identity MVC.
Build a role list in ASP.NET Core Identity MVC app by adding a role controller, injecting a role manager, and rendering an index view of roles with a create button.
Create an upsert view for roles in ASP.NET Core Identity MVC. The get endpoint fetches a role by id for update, or prepares a create form for new roles.
Add back, edit, and delete buttons for roles in the index view, wire them to actions with the role ID, apply bootstrap styling, and include a delete confirmation form.
Create and update role endpoints in the role controller, validate anti-forgery tokens, and use the role manager to prevent duplicates while updating name and normalized name asynchronously.
Implement role delete in the MVC app by retrieving the role by id from the database, using role manager's delete async, validating non-null, and confirming CRUD on the role list.
Add toaster notifications to the project by configuring toaster.js with jQuery, creating a shared partial for notifications, and using temp data keys for success and error messages.
Replace magic strings with constant error and success values in the role controller and toaster notification, updating temporary data handling to ensure reliable success messages.
Learn to prevent accidental deletion of roles in asp.net core identity mvc by validating assignments against the user roles mapping table and blocking deletion when users are linked.
Create a roles view model to manage a user's roles and support create, edit, and delete actions on roles. Include role selection with a role name and an isSelected flag.
Create a get endpoint to manage a user's roles, fetch the user by id, load current roles, enumerate all roles, mark assigned ones, and return a roles view model.
Create a manager role view in an ASP.NET Core MVC app using Razor, displaying user details and a roles list with checkboxes, then update the database with selected roles.
Remove existing roles from a user and assign newly selected roles via the roles view model, using the user manager's AddToRolesAsync method and proper model binding.
Display a lock or unlock button for each user on the user management page, using a form submit to toggle the account based on the logout end status.
Implement a post endpoint in the user controller to lock and unlock users by updating the lockout end time, validating anti-forgery tokens, and persisting changes to the application user.
Implement a delete user feature in ASP.NET Core Identity MVC with a confirmation dialog, http post endpoint, anti-forgery validation, and removal of the user followed by redirect and success message.
Explore using claims with ASP.NET Core Identity to control access, creating a claim store with create, edit, and delete claims and integrating them with roles for authorization.
Implement a manage user claim endpoint in ASP.NET Core Identity MVC by reusing the roles page pattern, creating a claims view model, and rendering claim selections from the claim store.
Implements a post endpoint to manage user claims by retrieving existing claims, removing old ones, and adding new claims from a multi-select claims view model, with validation and error handling.
Build a claims management view for managing user claims with full CRUD, update the ASP.NET user claims table, and align claim type with role name for admin access.
Assign and display multiple roles for users by updating account and user controllers to fetch roles with get role async, join them with commas, and show them correctly.
Set up a dummy access checker controller to demonstrate access rules with claims and roles, including endpoints for all, authorized, user, admin, and admin create access with a create claim.
Configure role-based access in the underscored layout by enabling admin and user endpoints, copying the access checker snippet from the project resources, and validating permissions in the app.
Master how allow anonymous and authorize attributes govern access in ASP.NET Core Identity MVC, with controller versus action level overrides and login redirection.
Explore role access in ASP.NET Core Identity by applying the authorize attribute with single and multiple roles, using predefined constants, and testing admin and user permissions.
Learn how to implement policy based authorization in ASP.NET Core by defining an admin policy in Program.cs with a role requirement, decoupling authorization from application logic, and protecting an endpoint.
Learn how policy based authorization overcomes role based limits by requiring both admin and user roles, and implement a policy named admin and user for the endpoint.
Explore policy-based authorization with ASP.NET Core Identity by creating admin claims, displaying claim types, and retrieving claims, noting that claim type is not case sensitive while claim value is.
Learn to implement policy-based authorization by requiring an admin role and a create claim, configure the policy in code, and enforce it on an endpoint.
Learn how to enforce a policy with multiple claims by adding admin role checks and create, edit, and delete claims to an endpoint, then validate access via authorization.
Configures a custom policy with a func-based assertion to grant access when an admin has all three claims or the user holds the super admin role.
Break complex authorization logic into a private boolean helper method using the authorization handler context, and call it in the require assertion; place it in a class file, not program.cs.
Implement a complex admin rule using a 1000-day requirement and its handler, and control access through policies with clear success, failure, and no action outcomes.
Implement a custom authorization handler to restrict role deletion to superadmins by creating a Superadmin checker, implementing IAuthorizationRequirement, and wiring it into a policy in program.cs.
Add a date created property to application user, create a migration to update the database, and use a custom policy for admin access to a special page after 1000 days.
Implement a days-for-account service using db context to compute account age, and enforce a policy granting access to the special page for admin users older than 1000 days.
Design a custom authorization requirement and handler to allow admin access based on a configurable days threshold, using dependency injection and a policy configured in program startup.
Add a first name claim for the user, refresh on login, and implement a custom policy and handler in program.cs to grant access when the name contains a string, case-insensitive.
Create a custom authorization handler and requirement to enforce a first name based access policy by retrieving user claims via user manager and applying it in program setup.
Implement single sign-on with Microsoft Entra by registering an app, retrieving client ID and secret, configuring the redirect URI, installing the Microsoft account auth package, and enabling login pages.
Display Microsoft login button on the login page by retrieving external authentication schemes from Program.cs and rendering a button for each provider.
Configure an external login endpoint in the account controller to initiate social login with a provider like Microsoft, using authentication properties and a redirect URL.
Create an http get endpoint for the external login callback in account controller, handling return url, remote error, and using sign in manager. Retrieve external login info and sign in.
Design the external login confirmation view with the external login confirmation view model, showing the provider name and a register action, and populate name and email from external claims.
Implement single sign-on with external login confirmation in an asp.net core identity mvc app, creating users from external info, validating models, and signing in via Microsoft.
Add Facebook login to an existing dotnet eight identity project by installing the Microsoft.AspNetCore.Authentication.Facebook NuGet package, configuring client ID and client secret, and validating the OAuth redirect URI.
Learn important skills for the new identity system for ASP.NET Core. Many times with the built in code developer misses the core concepts behind security in ASP.NET Core or how the Identity Razor class library behaves!
ASP.NET Core now includes the new identity system, which replaces the legacy membership system in ASP.NET. It is essential that software engineers learn these relevant skills and apply them when developing MVC applications if they do not want to combine razor pages with MVC
In this course we will build custom code with MVC for Identity Management similar to Identity Razor class library but with MVC. That way you can learn to stick with just one technology in your project.
Once we develop authentication with MVC and learn how to customize it.
We will also learn advance topics in authorization, as we start with basics and learn to dive into roles, claims and custom policy by building handlers, requirements and much more!
Authorization and User Management is a must in real world projects, and that is exactly what we will learn in this detailed course!
Course has been built using the latest .NET 8!
There is no course on Udemy that comes close the the topics explained in this course. I hope to see you guys in the learning journey!