GithubHelp home page GithubHelp logo

vonwenm / blazor.jwttest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shawty/blazor.jwttest

0.0 1.0 0.0 263 KB

Quick test using JWT authentication for a blazor hosted (Client/Serverside) app with API and Authentication.

License: MIT License

HTML 43.19% C# 53.87% CSS 2.95%

blazor.jwttest's Introduction

blazor.jwttest

Quick test using JWT authentication for a blazor hosted (Client/Serverside) app with API and Authentication.

Nothing Special, it simply has a login form, a changing nav bar based on login state, a small PostgreSQL based data layer that's designed to work with a postgres data base via EF Core (But should work with any DB that EF core supports)

It's not designed to be a mainstream project, it's me learning Blazor and trying to adopt the same ideas and programming model I already use for my Aurelia/.NET Core applications.

The template is more or less feature complete to what I wanted to make it do, it does however still run on Blazor 0.6.0 (See issue 1 in the issues for the reason)

features

  • JWT based token authentication
  • Roles from user record in database are used to prevent navigation to pages the logged in user does not have access too, and also protect the rest endpoints in the server
  • Custom component's and event based communication to parent pages
  • Generic design where permitted
  • all cross platform, dotnet core throughout
  • Entity framework datalayer, which will build initial database if run on an empty DB server, and seed data
  • Singleton based application state, accessible throughout the app

Note

This MUST be run on an empty PostgreSQL database. You'll need to update the connection string in the app settings file in the server project, then when run the app will create the two tables it needs and seed an initial user called "admin" with password "letmein"

If there are ANY objects at all in the DB your running against, the create will fail, and then when you run the app, you'll get errors about the tables not existing, I'll add some SQL scripts later on for those who want to create tables manually.

This should be useable against other DB's (since it uses EF) but I've not tested it, so you'll need to do some work yourself for that. It's all portable code however, and this is really just me playing around with and testing Blazor out, so don't expect amazing code :-)

Credit

Credit where credit is due, some large chunks of the code in here came from Chris Saintly at Codedaze.io and his article on doing JWT in a blazor app, I'd also like to say thanks to @SQL-MisterMagoo and @kswoll in the Blazor gitter group for pointers on component communication, and overriding the HTTP client to get better error handling.

blazor.jwttest's People

Contributors

shawty avatar sql-mistermagoo avatar

Watchers

James Cloos avatar

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.