I am trying to use meta annotations to simplify specifying permissions for my service. Ideally I would like to be able to write:
@PreAuthorize("#oauth2.hasScope('trust') && hasAuthority('$permission')")
annotation class RequiresPermission(val permission: String)
Which, of course, does not work, since permission is undefined yet, when we specify top level annotation.
Is there a way around this? Ideally, I would like to write something like:
annotation class RequiresPermission(val permission: String) = PreAuthorize("#oauth2.hasScope('trust') && hasAuthority('$permission')")
This is not correct Kotlin code, but perfectly expresses my intent.