https://kotlinlang.org logo
#ktor
Title
# ktor
c

CLOVIS

07/14/2022, 3:21 PM
Is there a way to have a route with optional authentication? I have a specific route that both users and anonymous clients can access.
e

Eric Grimsborn

07/14/2022, 4:26 PM
Maybe a bad idea but, you could create an auth provider that always succeeds authenticating and add that to the route since the
authenticate
function can be called with multiple configurations.
They actually have functionality for this…
Just add the parameter for optional
It will give you a
null
principal according to the documentation.
c

CLOVIS

07/14/2022, 5:38 PM
I have to give it to them that in insight it was extremely easy to find.