is now deprecated. What if I don't know the provider of my principals and I just want to get a list of them? That doesn't seem possible anymore?
a
Aleksei Tirman [JB]
04/05/2023, 8:24 PM
You can omit a provider’s name and just specify the type of a principal.
r
rocketraman
04/05/2023, 8:26 PM
Sorry, what I meant was, I don't know the type. It could be one of several types.
My workaround right now is an extension function that goes through the possible types and attempts to return them e.g.:
Copy code
fun AuthenticationContext.somePrincipal(): Principal? =
principal<JWTPrincipal>()
?: principal<MyCustomPrincipal>()
?: principal<AnonymousPrincipal>()
but that seems to be more work than is necessary when before I could just do:
Copy code
when(val principal = authentication.principal) {
...
}