This web app demos authentication using Json Web Token (JWT) following the tutorial by @Dzoukr. It is built with the SAFEr Template.
- .NET Core SDK 6.0 or higher
- Node LTS
- yarn
Before you run the project for the first time only you must install dotnet "local tools" with this command:
dotnet tool restore
Go to src/Server/appsettings.Development.json
and use your own JWT configuration.
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:
- Email:
bob@fsharp.net
- Password:
Str0ngP@zzword4Bob
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 build -t safe-auth-jwt .
docker run -it -p 5000:5000 safe-auth-jwt