Minimal Api Attributes
The testcode in my screenshot doesnt call the IAuthorizationFilter implementing attribute on my method head. when i use a inline delegate in programm.cs i loose DI(afaik).
i am sure there is a correct way, but for minimal apis i cant find it. Some tipps?
ps: in a controller api all works fina as expected.
17 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Also, minimal API doesn't support actionfilters. In .net 7 they support a new type of filter
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
its a custom attribute. and i know we all should use MS Identity, but this is a test and i do not see it usefull all the time. but this is another topic
so is IAuthorizationFilter the 1% or would you do stuff like this in middleware?
Authorize
isnt a filter iirc, its actually a flag for the middleware to kick inUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
gimme 20 minutes ill be right back
it just cheks on controllers/routes:
- is a custom allowanonymous attribute set
- is the user attatched to the context and are a few user criteria met(locked, permissions(also attributes on routes))
but as it seems, @Pobiega pointed out that it seems not working yet. so i wait till net7 to play around with this a bit more.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
dont get hung up on the authorize and best pacteces. this is just some tester project to play with stuff.
i might take a look into another approach without attributes. (thinking, for permissions i dont want to go without((
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
tebeco#0205
alternative:
Quoted by
<@!689473681302224947> from #Minimal Api Attributes (click here)
React with ❌ to remove this embed.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
tebeco#0205
Quoted by
<@!689473681302224947> from #Minimal Api Attributes (click here)
React with ❌ to remove this embed.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
tebeco#0205
or "docs aspnetcore resource based authorization"
Quoted by
<@!689473681302224947> from #Minimal Api Attributes (click here)
React with ❌ to remove this embed.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
resource based authorization looks interesting. its on my list for next weekend 🙂