I see that `AuthenticationContext.principal` is now deprecated. What if I don't know the provider of...
r
I see that
AuthenticationContext.principal
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
You can omit a provider’s name and just specify the type of a principal.
r
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) {
   ...
}
Hmm, ok, I guess I can just do
authentication.principal<Principal>()