Coder Social home page Coder Social logo

playingwithauthentication's Introduction

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

  • A simple WebAPI with a single html file. This is not a comprehensive example, just a checking the basics of cookie authentication.
  • Black-list: Implemented a solution to invalidate or reject a cookie based on the session ID.
  • Example of using ClaimsTransformation
Resources

Project: WebApi_EF_Identity

  • Take advantage of the Entity Framework Identity features, including UserManager and SignInManager.
  • Two Factor Authentication with AuthenticatorApp or Email
    • First: Register -> Confirm email
    • Flow #1: Get TwoFactor auth setup for Email -> Enable Email-TwoFactor with the given code -> Logout -> Login with user+pass -> Login with Email-TwoFactor with the given code (you got it after email+pass login)
    • Flow #2: Get TwoFactor auth setup for AuthenticatorApp by scanning the QR code -> Enable Authenticator-TwoFactor with a code -> Logout -> Login with user+pass -> Login with Authenticator-TwoFactor with a code
  • 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: WebApi_EF_Identity_BearerNET8

NET.8 introduced a new authentication method called BearerToken with new Identity endpoints (register, login). Just a few lines of code, you can have user management endpoints using Entity Framework. However, it is not suitable for custom needs and is more appropriate for local demo purposes. You can learn from the code to write your custom logic. See the WebApi_EF_Identity project.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.