Skip to content

Can Metalama add an aspect to a class? Thinking of creating a runtime AuthorizeAspectAttribute. #260

Answered by svick
HowardShank asked this question in Q&A
Discussion options

You must be logged in to vote

It seems to me that the main thing you need is to restrict access as soon as the underlying data changes and, as I understand it, you should be able to achieve that using CookieAuthenticationEvents.ValidatePrincipal.

Though since you also need a dynamic list of allowed roles, doing this with role-based authorization would require that the roles in your data are not the same as the roles in the app, but are dynamically mapped between each other. And I'm not sure this would be a good idea.

So you probably should consider either claims- or policy-based authorization, both of which allow you to execute code when authorizing an user.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@HowardShank
Comment options

@svick
Comment options

Answer selected by HowardShank
@HowardShank
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants