casbin-net / casbin-aspnetcore

Casbin.NET integration middleware and sample code for ASP.NET Core
https://github.com/casbin/Casbin.NET
Apache License 2.0
64 stars 20 forks source link

[samples] Consider add Blazor samples? #27

Closed LeiYangGH closed 1 year ago

LeiYangGH commented 3 years ago

Blazor

sagilio commented 3 years ago

Ok, but I don’t know enough about Blazor now, it may take some time.

hsluoyz commented 3 years ago

@LeiYangGH do you want to use C# Casbin in frontend? I think if you can import Casbin.NET lib in Blazor C# code, then you are free to use it. I don't know if there is anything blocking you? Or you can choose to use Node-Casbin (JS version) directly in frontend.

LeiYangGH commented 3 years ago

I'd like to use C# Casbin in frontend.

The repo already has a sample syntax like [CasbinAuthorize(nameof(BasicTest), nameof(HttpMethod.Get))], which is designed for asp.net core controller, right?

But a Blazor app can have no controller, it can have only razor page. so for a newbie(like me), there's no way to use the CasbinAuthorize attribute, at least there's no obvious way.

So I'd like suggest a Blazor sample.

if you can import Casbin.NET lib in Blazor C# code, then you are free to use it --- you're right. but on the other hand i don't agree with you, because if we only need the library, why create more framework(such as this repo, design specific asp.net core library)?

hsluoyz commented 1 year ago

@AsakusaRinne

/cc @sagilio

AsakusaRinne commented 1 year ago

@AsakusaRinne

/cc @sagilio

OK, I'll do it, but it may need some times to get familiar with it.

AsakusaRinne commented 1 year ago

I'd like to use C# Casbin in frontend.

The repo already has a sample syntax like [CasbinAuthorize(nameof(BasicTest), nameof(HttpMethod.Get))], which is designed for asp.net core controller, right?

But a Blazor app can have no controller, it can have only razor page. so for a newbie(like me), there's no way to use the CasbinAuthorize attribute, at least there's no obvious way.

So I'd like suggest a Blazor sample.

if you can import Casbin.NET lib in Blazor C# code, then you are free to use it --- you're right. but on the other hand i don't agree with you, because if we only need the library, why create more framework(such as this repo, design specific asp.net core library)?

Hey, A Blazor app can have no controller, it can have only razor page ----- I guess you mean the server mode of Blazor. Besides it, Blazor also has client mode, which has controllers and frontend. Have you considered using the client mode?

hsluoyz commented 1 year ago

Fixed by: https://github.com/casbin-net/casbin-aspnetcore/pull/52

hsluoyz commented 1 year ago

@LeiYangGH

LeiYangGH commented 1 year ago

thanks a lot!