Giter Club home page Giter Club logo

safe-auth-jwt's Introduction

SAFE Authentication with JWT Bearer token

This web app demos authentication using Json Web Token (JWT) following the tutorial by @Dzoukr. It is built with the SAFEr Template.

Prerequisites

How to run

1. Restore .NET local tools

Before you run the project for the first time only you must install dotnet "local tools" with this command:

dotnet tool restore

2. Define JWT configuration

Go to src/Server/appsettings.Development.json and use your own JWT configuration.

3. Run the app

To concurrently run the server and the client components in watch mode use the following command:

dotnet run

Then open http://localhost:8080 in your browser.

Login credentials:

Notes

Some notes taken from the tutorial:

  • Exceptions are used for errors, but with well-defined union type inside
  • Remoting uses custom error handler to wrap such errors and set 4xx status code for HTTP response
  • API definition does not use Result type directly
  • Registration neither token refresh is not part of this example, but can be easily added
  • Database for users and its functions are not implemented, only used "to implement" functions
  • Authentication is hard - don't do it manually. Use some existing service like Auth0, Azure AD, Identity Server or so.

Docker

docker build -t safe-auth-jwt .
docker run -it -p 5000:5000 safe-auth-jwt

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.