Giter Club home page Giter Club logo

blazorwithidentity's Introduction

Blazor with Identity

Build status Nuget (with prereleases) Nuget Donate

A project template for a blazor wasm hosted app using cookie based authentication with ef core identity

Using the template

  1. Install the template
dotnet new --install BlazorWithIdentity.Template
  1. Create a new project
dotnet new blazorwithidentity -o MyBlazorApp

How to run

  1. Install the latest dotnet sdk and the latest Visual Studio.
  2. Clone or download.
  3. Open the solution in the template folder and press F5.
  4. Create a user using the Create Account button in the login page or login if you have already created a user.

Live demo

https://blazorwithidentity.azurewebsites.net/

blazorwithidentity's People

Contributors

plbonneville avatar rico-rodriguez avatar stavroskasidis avatar tbgrenfold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blazorwithidentity's Issues

iOS Device Loading Issue

I was looking at your project and one test was seeing what devices were supported. I know that Blazor supports iOS devices but in my testing, iPod Touch, iPhone, iPad and iPad Air, none of them would load your site. I've tested other Blazor sites on iOS devices without issues. Is this a known issue that you've looked into?

Thank you for your time!
Bryan

AuthorizeController.Login returns a stale UserInfo

After the call to SignInAsync, you return Ok(BuildUserInfo()) which in turn uses the inhertied User property from the ControllerBase which is not updated to reflect the new user but still holds an unauthenticated user.
Luckily, IdentityAuthenticationStateProvider.GetAuthenticationStateAsync retrieves an updated UserInfo if the cached user info is unauthenticated but you end up with an extra trip to the back-end.

User.Identity.IsAuthenticated false although SignIn Succeeded

I have a Blazor WASM with a very similar sign in process. But all of a sudden on my local computer User.Identity.IsAuthenticated returns false even right after the signIn returned Succeeded. So I checked with your project and I have the same result here. Do you have any idea what causes that?

PW Reset

For completeness it would nice to add a password reset feature in the demo code

Security Question

Do you feel this template does a good job protecting against XSS and CSRF?

Simple CRUD?

What's the best practice for adding simple CRUD to this? Is the dbContext reusable for storing data other than the auth related stuff, or should it be done entirely separately?

Not working - no cookie set by API when logged in

I tried this yesterday on Preview 3 and it worked when I registered a user.

Upgraded to the Preview 4 version today, and it isn't working. When I log in, the request is validated by the API. I can see the cookie returned in the API call response.
image

However, when the redirect to the root page takes place, the cookie isn't present, so the it does not appear to be logged in?
image

Role-based authorization

First of all, thank you very much for the nice template. How could I extend the template to support role-based authentication? Could you provide an example or direct me?

Thank you

Latest version

Is that possible to update this example to the latest version of Blazor?

Client Can't login.

A Problem. Blazor Client Can't login. after I Create a account. in Chrome.

But OK in Microsoft Edge.

How did you deploy this application to Azure?

I really want to use this template but am curious how you deployed this to Azure. Do you have anything detailing how you deployed both web applications to work together? Did you have it use SQLlite in Azure?

Will not get user details for user already logged in

An issue with this library (good as it is!) is that the Username is only populated if the user logs in or registers using the API. The username isn't re-populated if the user is already logged in on returning.

However his royal Blazorness Steve Sanderson says that ClaimsPrincipal will be made available in a later version (see dotnet/aspnetcore#4048)

Using Sql Server as the Database

I try to change the sqlite to sql server, but got error 500
Step i done :

  1. Adding Microsoft.EntityFrameworkCore.SqlServer
  2. Change : services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite("Filename=data.db")); to services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connString));

When i register, the input username & password is inserted to database, but it say error 500
I cant login

Does it work with Blazor Server?

Does this approach work with Blazor Server? There are implementation differences.

One thing I don't understand... where is the login token actually being stored?

Project Future

Great template! I set up Identity in no time.
What are the future plans for the project?
I could easily see this incorporating all the Identity scaffolding including 2FA.

IsLoggedIn issue

Thanks for this nice sample!

I've noticed that the cookie inspection logic (Authorization_LoginCookieExists) also reports true if the user is logged in at any other ASP.NET Core Identity site that uses cookie authentication because that other site would also set a cookie.

Would it be possible to instead simply try and get the user info right away as it's going to be needed anyway (and as suggested by #3)? Then, the IsLoggedIn method becomes a simple this.userInfo != null check and there would be no JS interopping. Would that make sense?

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.