You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the beans viewAccessChecker and accessAnnotationChecker are the core security handlers when using vaadin 21+
There are number of reasons why one would like to provide a custom AnnotationCheker or ViewAccessChecker. You could implement custom or new authorisation schema!
(No) Abstraction
While there is a way to forcefully overwrite the beans provided by vaadin using @Primary there are still t issues
Its not documented so noone knows to use @Primary and if they do they cant name their bean viewAccessChecker
There is no abstraction for AccessChecker and AnnotationChecker which makes overwriting them quite hacky - you nearly need to use reflections to set a private field which is a big nono.
Quickfix
For users that need to solve this specific problem at the moment there is a (little hacky) workaround:
Lets assmue you want 2 custom annotations @Public and @Private (keep it simple for sake of example
Then you need to impement a custom Annotation Checker
publicclassCustomAnnotationCheckerextendsAnnotationAccessChecker {
@OverridepublicbooleanhasAccess(Methodmethod, Principalprincipal, Function<String, Boolean> roleChecker) {
//THIS IS NOT A PROPPER IMPL. JUST AN EXAMPLE -> Blocks everybody from @Private and just allows @Publicreturnthis.getSecurityTarget(method).isAnnotationPresent(Public.class);
}
@OverridepublicbooleanhasAccess(Class<?> cls, Principalprincipal, Function<String, Boolean> roleChecker) {
returnthis.getSecurityTarget(cls).isAnnotationPresent(Public.class);
}
}
Then you need to overwrite the annotation checker bean
You are done :) ... no not rly because for some reason ViewAccessChecker does not uses the bean but instanciates the object itself so you need to overwrite this bean too.
If this issue is accepted as an issue and the changes are ok with the devs i will implement the changes myself and create a PR to take the load of the core devs
Add interface for AnnotationAccessChecker
Add interface for ViewAccessChecker
add @ConditionalOnMissingBean to all beans provided by vaadin and therefore encouraging overwriting without introducing incompatibilities
The text was updated successfully, but these errors were encountered:
Issue
the beans
viewAccessChecker
andaccessAnnotationChecker
are the core security handlers when using vaadin 21+There are number of reasons why one would like to provide a custom AnnotationCheker or ViewAccessChecker. You could implement custom or new authorisation schema!
(No) Abstraction
While there is a way to forcefully overwrite the beans provided by vaadin using
@Primary
there are still t issues@Primary
and if they do they cant name their beanviewAccessChecker
Quickfix
For users that need to solve this specific problem at the moment there is a (little hacky) workaround:
Lets assmue you want 2 custom annotations
@Public
and@Private
(keep it simple for sake of exampleSo you annotate your View With
Then you need to impement a custom Annotation Checker
Then you need to overwrite the annotation checker bean
You are done :) ... no not rly because for some reason
ViewAccessChecker
does not uses the bean but instanciates the object itself so you need to overwrite this bean too.Proposed Changes
AnnotationAccessChecker
ViewAccessChecker
@ConditionalOnMissingBean
to all beans provided by vaadin and therefore encouraging overwriting without introducing incompatibilitiesThe text was updated successfully, but these errors were encountered: