-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
IMovieService example can lead to authorization problems #34586
Comments
💃🕺🥳 Happy New Year! 🎈🎆🍾🥂🎉Stand-by! ... A green dinosaur 🦖 will be along shortly to assist. |
Hello @davisnw ... Let me get back to you on this, hopefully tomorrow morning (Thursday). |
I'm back! Sorry for the delay.
It's not covered here at the moment. Secure web APIs are covered by the main doc set articles, which apply to most Blazor scenarios (especially on the server-side), and the Blazor node Security and Identity articles. I want to mention in passing that a goal for the Blazor sample apps was to include secure web API calls. Devs can follow the patterns for typical secure web API call scenarios. Here are the examples:
I agree with you that this article and the sample apps for it should include basic security patterns. I'll schedule this issue for work, and I hope to reach it within the next couple of weeks. Notes for updating the article and samples:
On your last point, you wrote ...
I don't follow. There's the service for server-rendered components (SSR), and there are the endpoints for web API calls for CSR. The "Backend" app only manages Todo list examples. What's the third "implementation" that you're referring to for the movie examples? |
I don't see this as particularly relevant to this issue?
I don't currently have an Entra instance readily available to run this example, however, from inspecting the code, the
Same comments on 9.0/BlazorWebAppEntra/BlazorWebAppEntra.sln apply to 9.0/BlazorWebAppOidc/BlazorWebAppOidc.sln
What I meant was:
|
Yes, working on standalone WASM web API security isn't the focus of your issue, but I'd like to work on it at the same time. I'm going to use your issue in a general way to address web API security in this article. On your second point, I understand, but this is what the product unit has advised developers to do (at least so far 😄). To discuss or pitch alternatives, you would need to open an issue on their repo. We only work on docs here. They work on the framework from the https://github.com/dotnet/aspnetcore/issues Please add ...
... to the bottom of your opening comment so that I can follow along. I'd like leave your issue open here for work, so don't close this. On the third point ... the "third" implementation ... I understand you're referring to the endpoint security "implementation" paradigm. However, that discussion would need to go to the product unit engineers. This is the strategy that they currently recommend. If you open an issue, I'll definitely follow the discussion that you have with them, looking for ways to improve the guidance. |
Description
The page gives an example of creating a common interface
IMovieService
with two implementations:ClientMovieService
andServerMovieService
.Neither the page nor the linked github code example (
BlazorWebAppCallWebApi
) have any discussion of the ASP.NET Core endpoint authorization.So, for example, since
ClientMovieService
goes through "web api", traditional authorization attributes such as[Authorize("MyPolicy")]
could be applied to individual endpoints (so e.g. Updating a movie has different permissions than reading a movie), however, the same operation in SSR going throughServerMovieService
implementation would not have any of those authorization attributes applied.This bifurcation of authorization stacks seems like an area rife for security holes, so some discussion of handling authorization when providing multiple implementations of a service for client-side vs server-side rendering seems to be warranted.
To further add to some of the confusion, in the github sample (
BlazorWebAppCallWebApi
), there is a tremendous amount of duplication in the minimal api spec and theServerMovieService
:So now there are actually 3 separate implementations of the movie related functionality.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/blazor/call-web-api?view=aspnetcore-9.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/call-web-api.md
Document ID
c7e59a08-1c60-32c2-75fd-33cb77ff7a5d
Article author
@guardrex
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: