AuthPermissions.AspNetCore icon indicating copy to clipboard operation
AuthPermissions.AspNetCore copied to clipboard

Create Blazor Demo

Open akema-trebla opened this issue 2 years ago • 27 comments

It appears there's a lot of interest in an AuthP demo with a Blazor application.

I noticed one of the Discussions (#31), wanted to find out how to do this from a Blazor WASM application in particular.

So with @JonPSmith's blessing, I'll be taking the Example 4 project and converting it into a Blazor application.

I'll be creating

  • A Web API backend project
  • A Blazor WASM hosted project

akema-trebla avatar May 30 '22 09:05 akema-trebla

Hi @akema-trebla,

Great to see you doing this!

I just wanted to alert that I am currently improving Example3 (in the dev branch) with a better "sign up / versioning" and "invite user" features. These features / new release and a few other changes will be merged back into main branch in 2 to 4 weeks (hopefully).

I don't want that to cause a problems to you so here are some suggestions:

  • Remove the "sign up" and "invite user" code from your new example - I think that is best way as the focus is on Blazor
  • Copy the Example3 code and store it somewhere - that's messy, but possible.

Anyway, just wanted to let you know. If you have any questions then add a comment to this issue.

JonPSmith avatar May 30 '22 14:05 JonPSmith

It appears there's a lot of interest in an AuthP demo with a Blazor application.

I noticed one of the Discussions (#31), wanted to find out how to do this from a Blazor WASM application in particular.

So with @JonPSmith's blessing, I'll be taking the Example 4 project and converting it into a Blazor application.

I'll be creating

  • A Web API backend project
  • A Blazor WASM hosted project

Hi @akema-trebla, That will be awesome and appreciated very much. Thank so much for your effort and time.

Also please have a look at this those 2 libraries they may be very helpful for you 1 - https://github.com/fullstackhero/dotnet-webapi-boilerplate 2 - https://github.com/fullstackhero/blazor-wasm-boilerplate

T-Alkathiri avatar May 31 '22 04:05 T-Alkathiri

It appears there's a lot of interest in an AuthP demo with a Blazor application. I noticed one of the Discussions (#31), wanted to find out how to do this from a Blazor WASM application in particular. So with @JonPSmith's blessing, I'll be taking the Example 4 project and converting it into a Blazor application. I'll be creating

  • A Web API backend project
  • A Blazor WASM hosted project

Hi @akema-trebla, That will be awesome and appreciated very much. Thank so much for your effort and time.

Also please have a look at this those 2 libraries they may be very helpful for you 1 - https://github.com/fullstackhero/dotnet-webapi-boilerplate 2 - https://github.com/fullstackhero/blazor-wasm-boilerplate

Thanks @T-Alkathiri

I've actually had a look at and contributed to the fullstackhero project in the past.

I've also been able to integrate AuthP in that project.

I was just kinda waiting for @JonPSmith's changes since I was actually already done by the time he mentioned them :-)

akema-trebla avatar Jun 21 '22 07:06 akema-trebla

Hi @akema-trebla,

Version 3.3.0 is out now and merged into the main branch. It has some changes, but its mainly new code. I'm not working on the AuthP at he moment

JonPSmith avatar Jun 21 '22 08:06 JonPSmith

Hi @akema-trebla,

Version 3.3.0 is out now and merged into the main branch. It has some changes, but its mainly new code. I'm not working on the AuthP at he moment

Alright, thanks @JonPSmith

akema-trebla avatar Jun 22 '22 06:06 akema-trebla

Hi @akema-trebla, Version 3.3.0 is out now and merged into the main branch. It has some changes, but its mainly new code. I'm not working on the AuthP at he moment

Alright, thanks @JonPSmith

Hi @akema-trebla,

When do you think will you finish with the Blazor example? I can't wait to see the example!! :)

ebasattend avatar Aug 25 '22 17:08 ebasattend

Hi @ebasattend

Sorry for the delay. I actually had to put work on hold for a while. I resume today and I'll get back to this towards the end of the week.

Cheers!

akema-trebla avatar Aug 29 '22 11:08 akema-trebla

Hi @akema-trebla, Any news on this?

ebasattend avatar Sep 16 '22 14:09 ebasattend

Hi @ebasattend

I've been quite busy but I've been able to complete the WebApi and it's left with the Blazor WASM side.

I'll submit the pull request as is for now so it gives you a starting reference. Seems I'll be getting some help from @idan-h so hopefully it should be completed soon.

akema-trebla avatar Sep 29 '22 15:09 akema-trebla

Hello, again guys any news on blazor sample?

ebasattend avatar Oct 24 '22 16:10 ebasattend

@akema-trebla has created a PR of the backend part about a month ago, but we agreed that its not worth merging until he has build Blazor part is finished.

JonPSmith avatar Oct 27 '22 19:10 JonPSmith

Thanks @JonPSmith for providing the update. I just noticed you've completed the feature to change claims for the JWT.

I'll take a look and see what changes need to be made so I can add the frontend.

@ebasattend As @JonPSmith stated you can find the backend under the closed PRs as a starting reference. We'd agreed to merge after the frontend was added and after the claims change feature was implemented as well.

I have sometime in the coming week so we should have this sorted out in the coming week. Thanks for your patience.

akema-trebla avatar Nov 05 '22 19:11 akema-trebla

Hi @akema-trebla,

I think you are too busy to complete this large version. I understand your position, as I can only support this library because I have stopped doing client work.

If I don't hear from you in the next week or so I will close this issue as "no planned".

All the best to you and your career.

JonPSmith avatar Jan 03 '23 12:01 JonPSmith

Hi @JonPSmith

Happy new year.

I agree. This has taken longer than even I expected but I do want to do this.

I'll reach out on the PR branch to find out what changes I need to work on so I can do those and then link it to the Blazor frontend.

akema-trebla avatar Jan 05 '23 21:01 akema-trebla

Before a final decision is made on this issue I would like to explore if I can assist in this effort. I don't know what you have in mind for the Blazor demo, but if any of the following dovetails in, let me know.

I am working on a Blazor Server app (non-public) using a backend API that implements AuthP. The Blazor-side authorization is manifested through a permission-trimmed menu structure that only exposes menu items the user is allowed to access based on AuthP. Unauthorized menu items are not exposed on the browser side so security exposure is minimized.

I know this is pretty high level. Let me know if any of the concepts resonate with your efforts.

Code420SW avatar Jan 07 '23 02:01 Code420SW

Hi @akema-trebla,

That's fine. Great that you want to finish this. I just didn't this issue to to be open if nothing was going to happen. I'll keep it open.

JonPSmith avatar Jan 08 '23 09:01 JonPSmith

Hi @Code420SW,

Great that you are building a demo of Blazor with the AuthP library. But I see that you are using Syncfusion, which isn't a open-source. That doesn't mean you can write / tweet about it, but it can't be part of this repro.

@akema-trebla is trying to create a Blazor app from scratch, using the AuthP library. It is a big job but he has built the backend and is now looking at the frontend.

All the best with your project.

JonPSmith avatar Jan 08 '23 09:01 JonPSmith

Rediet Zewdu asked if he could create a Blazor web assembly that uses AuthP library. The answer is no for the following reasons.

  • Blazor web assembly can have parallel database assesses and EF Core’s DbContext isn’t thread-safe – see this document.
  • Blazor web assembly doesn’t support authorization because anyone can alter the code – see this explanation.

You need to have a Blazor Server which runs on a web server and send the date to the front-end. I'm not an expert on Blazor (I'm more a backend coder), but you can look at the Blazor docs.

Also @akema-trebla is building an example Blazor app using the AuthP library, but its a lot of work and he isn't getting paid to do this, so it done in his spare time.

JonPSmith avatar Jan 22 '23 11:01 JonPSmith

Rediet Zewdu asked if he could create a Blazor web assembly that uses AuthP library. The answer is no for the following reasons.

  • Blazor web assembly can have parallel database assesses and EF Core’s DbContext isn’t thread-safe – see this document.
  • Blazor web assembly doesn’t support authorization because anyone can alter the code – see this explanation.

You need to have a Blazor Server which runs on a web server and send the date to the front-end. I'm not an expert on Blazor (I'm more a backend coder), but you can look at the Blazor docs.

Also @akema-trebla is building an example Blazor app using the AuthP library, but its a lot of work and he isn't getting paid to do this, so it done in his spare time.

Hey Jon, ofcourse you can build wasm app with AuthP.

You will need a backend api which would be implemented with the help of AuthP library, and a then make api calls from the client side (wasm) as usual.

The authentication should be implemented with JWT or cookies.

Blazor contains client side auth out of the box, so you don't need to implement that manually.

As I said earlier, we have just created such project at our company. Currently I am swamped so I couldn't start working on a generic example, but I would be glad to help if anyone is working on it.

idan-h avatar Jan 22 '23 12:01 idan-h

Rediet Zewdu asked if he could create a Blazor web assembly that uses AuthP library. The answer is no for the following reasons.

  • Blazor web assembly can have parallel database assesses and EF Core’s DbContext isn’t thread-safe – see this document.
  • Blazor web assembly doesn’t support authorization because anyone can alter the code – see this explanation.

You need to have a Blazor Server which runs on a web server and send the date to the front-end. I'm not an expert on Blazor (I'm more a backend coder), but you can look at the Blazor docs.

Also @akema-trebla is building an example Blazor app using the AuthP library, but its a lot of work and he isn't getting paid to do this, so it done in his spare time.

Hey Jon, ofcourse you can build wasm app with AuthP.

You will need a backend api which would be implemented with the help of AuthP library, and a then make api calls from the client side (wasm) as usual.

The authentication should be implemented with JWT or cookies.

Blazor contains client side auth out of the box, so you don't need to implement that manually.

As I said earlier, we have just created such project at our company. Currently I am swamped so I couldn't start working on a generic example, but I would be glad to help if anyone is working on it.

Thank you for your interest to help out. Could you please show me some direction so that I can follow or sample project. Thanks in advance.

zrediet avatar Jan 22 '23 13:01 zrediet

Rediet Zewdu asked if he could create a Blazor web assembly that uses AuthP library. The answer is no for the following reasons.

  • Blazor web assembly can have parallel database assesses and EF Core’s DbContext isn’t thread-safe – see this document.
  • Blazor web assembly doesn’t support authorization because anyone can alter the code – see this explanation.

You need to have a Blazor Server which runs on a web server and send the date to the front-end. I'm not an expert on Blazor (I'm more a backend coder), but you can look at the Blazor docs.

Also @akema-trebla is building an example Blazor app using the AuthP library, but its a lot of work and he isn't getting paid to do this, so it done in his spare time.

Hey Jon, ofcourse you can build wasm app with AuthP.

You will need a backend api which would be implemented with the help of AuthP library, and a then make api calls from the client side (wasm) as usual.

The authentication should be implemented with JWT or cookies.

Blazor contains client side auth out of the box, so you don't need to implement that manually.

As I said earlier, we have just created such project at our company. Currently I am swamped so I couldn't start working on a generic example, but I would be glad to help if anyone is working on it.

Thank you for your interest to help out. Could you please show me some direction so that I can follow or sample project. Thanks in advance.

As of the backend, you can use the api example from project 2 in the solution.

I don't like all the choices they made here and a lot of code needs to be trimmed down / changed, but it is a good example of wasm blazor capabilities: https://github.com/fullstackhero/blazor-wasm-boilerplate

idan-h avatar Jan 22 '23 14:01 idan-h

There's a working API using AuthP here

We just need to create a Blazor frontend for it.

And yes, we can use Blazor WASM as I plan to do.

@idan-h Can we collaborate on the frontend? Or you're too busy?

akema-trebla avatar Jan 22 '23 18:01 akema-trebla

There's a working API using AuthP here

We just need to create a Blazor frontend for it.

And yes, we can use Blazor WASM as I plan to do.

@idan-h Can we collaborate on the frontend? Or you're too busy?

Sure, we can collaborate, I'll help with the general structure of the project and will try to help whenever I have free time.

idan-h avatar Jan 22 '23 20:01 idan-h

@idan-h What structure do you propose?

akema-trebla avatar Jan 23 '23 15:01 akema-trebla

Clean architecture would be a good fit!

On Mon, Jan 23, 2023, 6:03 PM akema-trebla @.***> wrote:

@idan-h https://github.com/idan-h What structure do you propose?

— Reply to this email directly, view it on GitHub https://github.com/JonPSmith/AuthPermissions.AspNetCore/issues/38#issuecomment-1400497298, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALOL2GI6X3RFJWTG2P6U73TWT2MUVANCNFSM5XJ6BKAA . You are receiving this because you commented.Message ID: @.***>

zrediet avatar Jan 23 '23 17:01 zrediet

Clean architecture would be a good fit!

On Mon, Jan 23, 2023, 6:03 PM akema-trebla @.***> wrote:

@idan-h https://github.com/idan-h What structure do you propose?

— Reply to this email directly, view it on GitHub https://github.com/JonPSmith/AuthPermissions.AspNetCore/issues/38#issuecomment-1400497298, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALOL2GI6X3RFJWTG2P6U73TWT2MUVANCNFSM5XJ6BKAA . You are receiving this because you commented.Message ID: @.***>

Clean architechture is an overkill for this project IMO, and I like feature slicing better in most cases.

A simple and clean folders of Components, Pages, Services etc in would be sufficient.

We will create services which will be responsible of server calls injected with DI.

I still need to take a look at the api project to see what contracts should be shared between the client and the server.

As for comunication between components (We might not need it, depends if we need to manage general state between components) I would use microsot mvvm toolkit. It has a messenger feature that comes in handy.

We can start by forking the project I sent above and changing the namespace to be in line with the server side (The api) and AuthP library in general. Then I would like to start trimming it down to get the appropriate project structure.

Does it sound good for you guys?

@akema-trebla @zrediet @JonPSmith

idan-h avatar Jan 23 '23 18:01 idan-h

Sounds good to me.

On Mon, Jan 23, 2023, 9:42 PM Idan @.***> wrote:

Clean architecture would be a good fit!

On Mon, Jan 23, 2023, 6:03 PM akema-trebla @.***> wrote:

@idan-h https://github.com/idan-h https://github.com/idan-h What structure do you propose?

— Reply to this email directly, view it on GitHub #38 (comment) https://github.com/JonPSmith/AuthPermissions.AspNetCore/issues/38#issuecomment-1400497298 , or unsubscribe

https://github.com/notifications/unsubscribe-auth/ALOL2GI6X3RFJWTG2P6U73TWT2MUVANCNFSM5XJ6BKAA . You are receiving this because you commented.Message ID: @.***>

Clean architechture is an overkill for this project IMO, and I like feature slicing better in most cases.

A simple and clean folders of Components, Pages, Services etc in would be sufficient.

We will create services which will be responsible of server calls injected with DI.

I still need to take a look at the api project to see what contracts should be shared between the client and the server.

As for comunication between components (We might not need it, depends if we need to manage general state between components) I would use microsot mvvm toolkit. It has a messenger feature that comes in handy.

We can start by forking the project I sent above and changing the namespace to be in line with the server side (The api) and AuthP library in general. Then I would like to start trimming it down to get the appropriate project structure.

Does it sound good for you guys?

@akema-trebla https://github.com/akema-trebla @zrediet https://github.com/zrediet @JonPSmith https://github.com/JonPSmith

— Reply to this email directly, view it on GitHub https://github.com/JonPSmith/AuthPermissions.AspNetCore/issues/38#issuecomment-1400809473, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALOL2GNTYTFXTAU7N2HBPGLWT3GIVANCNFSM5XJ6BKAA . You are receiving this because you were mentioned.Message ID: @.***>

zrediet avatar Jan 24 '23 04:01 zrediet