-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Blazor] Use shared policies for client and server #12391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi. It looks like this is a question about how to use ASP.NET Core. While we do our best to look through all the issues filed here, to get a faster response we suggest posting your questions to StackOverflow using the asp.net-core-blazor tag. |
Added question on StackOverflow: https://stackoverflow.com/questions/57150701/use-same-authorization-policies-for-client-and-server-in-blazor Those mixed versions and the unknown compability between |
@mkArtakMSFT After further investigation, this is definietly an issue with the That way, shared policies are not possible. Therefore, I'd rather call this issue a bug or feature request, not a question. The following error is caused by adding the package, causing the client project build to fail:
Followed up by this cryptic error message:
|
Example project on GitHub: https://github.com/Herdo/hou-units/tree/prototype-blazor/src/UNITS |
Hi @Herdo thanks for contacting us. Is the IdentityConstants the only thing you are using from that assembly? (Seems like it) I have a few suggestions:
My final suggestion would be to follow the path of least resistance, while keeping things DRY is a good principle to follow, you need to take into account the price you are paying and the benefit you are getting from it on a per case basis. Hope this helps. |
@javiercn Yes, Not a single one suggest hard-coding I know that this re-use is hurting a lot, and after your comment I don't plan to keep it that way, but rather go back to the hard-coded solution. Thank you very much for your help. |
Scenario
In my ASP.NET Core hosted client-side Blazor application, I want to use my policies in both projects.
The current project template creates the following projects:
Problem
The clear approach would be to define the policies in the shared project, once.
However, policies defined in the shared project are not available in the server project.
This is partially due to the changes listed in #3756, as well as the fact that the
Microsoft.AspNetCore.Identity.IdentityConstants
are not available in the .NET Standard 2.0 project.Possible options
IMHO, it should be possible to use the same policies for the server and client project, without having to define them twice. Three options I can currently come up with:
MyProject.Server
andMyProject.Client
project (insufficient option).The text was updated successfully, but these errors were encountered: