Giter Club home page Giter Club logo

minimalapistemplate's Introduction

MinimalAPIsTemplate

Complete and working ASP.NET Core Minimal APIs template, with OAuth 2.0 Authentication using JSON Web Algorithms and Tokens (JWA, JWT, JWS, JWE) as Bearer.

Examples of implemented APIs ready to go:

  • JWT unsigned and not encrypted for basic knowledge
  • JWS ("alg": "HS512") signed with HMAC SHA-512 using a symmetric key
  • JWS ("alg": "RS512") signed with RSA SHA-512 using a X509 Certificate asymmetric key
  • JWE ("enc": "A256CBC-HS512", "alg": "dir") encrypted with AES256 using a symmetric key and signed with HMAC SHA-512 using a symmetric key
  • JWE ("enc": "A256CBC-HS512", "alg": "dir") encrypted with AES256 using a symmetric key and signed with RSA SHA-512 using a X509 Certificate asymmetric key
  • Login (authentication) test with one of the generated Bearer token

Other examples in this template:

  • Minimal APIs architecture pattern with Handlers, Endpoints, Authentication and Authorization
  • Examples of asynchronous service calls with Dependency Injection (DI) and scoped services
  • Examples of support to Docker, Entity Framework, Swashbuckle (OpenAPI Swagger), Hangfire
  • Examples of Hsts, Exception Handler, Json Console, Health Checks and other services and middlewares

How to use

  1. Call a generate token method and copy the returned Bearer token token
  2. Log in clicking the Authorize green button in the Swagger UI and enter the value: "Bearer token" (without double quotes, replace token with its value)
  3. Call tryToken method. You will get 200 if authenticated, 401 otherwise

How to generate a PFX certificate

Use the following commands to generate a .pfx file using OpenSSL for Windows, then copy it to the Certificates folder of the project:

openssl genrsa -aes256 -out sign-key.pem 2048  
openssl req -new -x509 -sha256 -outform pem -key sign-key.pem -days 365 -out sign-cert.pem  
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.pem  

Sources and useful links

  1. RFC 7518: JSON Web Algorithms (JWA) - https://www.rfc-editor.org/rfc/rfc7518

minimalapistemplate's People

Contributors

georgep11 avatar

Watchers

 avatar

Forkers

derkodex

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.