/PlayingWithAuthentication

Try out different authentications

Primary LanguageC#

Playing with Authentication

Table of content


Project: KeyGenRSA

  • Console application to generate private and public RSA pem files.
  • Private key is used in the ApiJWT project to sign and validate JWT.
  • Public key can be used to validate an ApiJWT token. It can be an RsaSecurityKey during authentication process passing the ApiJWT token.
  • Hashing and Salting password with PBKDF2.
Resources

Project: ApiJWT

  • WebAPI using JWT authentication, signing the token with the RSA private key.
  • Create SigningCredentials with symmetric and asymmetric security key using RSA or X509Certificate.
  • Implement a method for refreshing the token.
  • Implement a method for invalidating the token.
Resources

Project: ApiCookieAuth

  • Implements a cookie authentication.
  • Call the ApiJWT service to obtain a token and store it in the AuthenticationProperties for future use.
  • Implement a method for adding sessions to the black list.
Resources

Project: WebApi_EF_Identity

  • Take advantage of the Entity Framework Identity features, including UserManager and SignInManager.
  • Two Factor Authentication with AuthenticatorApp or Email
    • Flow: Register -> Confirm email -> Get TwoFactor auth setup -> Enable TwoFactor -> Logout -> Login -> Login with TwoFactor
  • Generating a short-lived token for signing in like Slack and Medium
  • Recovery codes for 2FA can be generated. After logging in with your username and password, you can use one of these codes instead of the authenticator code.
Resources

Project: ApiKeyAuth

The following solutions have been implemented

  1. Use a custom middleware to check the API Key
  2. Add an authorization filter for all endpoints of the Controller
  3. Apply an authorization filter individually (controller and/or endpoint level) with an attribute
  4. Add an endpoint filter for minimal API
  5. Add a custom authentication handler and use the [Authorize] attribute
Resources

Project: BlazorWASM.BFF.Auth0.OpenIDConnect

  • An example of using Auth0 with OpenIDConnect in a Blazor WebAssembly application that has a Backend For Frontend (BFF) architecture.
  • Damien’s template is used to create 3 projects: Client, Server and Shared and customized for Auth0.
  • For more information

Project: BlazorWASM.Auth0.JWT.OpenIDConnect

Other resources
Password hashing