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

addamsson

04/24/2020, 11:19 AM
How do I perform
Bearer
authentication with #ktor ? I see that there is basic, jtw, etc, but there is no option for simply checking the bearer token.
o

Orhan Tozan

04/24/2020, 12:24 PM
I think you have to manually set the header for that.
r

Rachid

04/24/2020, 12:27 PM
I'm not sure if I understand your question correctly, but shouldn't the OAuth Provider be responsible for authentication?
Where for JWT you can do this in KTor itself, but for OAuth this will be done by the 3rd party
a

addamsson

04/24/2020, 12:28 PM
no, i want to use
Bearer
tokens
I'm also using JJTW and ktor uses Auth0's JWT implementation so it is not an option for me
it is also very hard to customize
i want to use JWTs for form authentication and API authentication as well
d

Dennis

04/24/2020, 12:57 PM
if you’re using JWT then you can hook into jwt’s
authHeader
to return an HttpAuthHeader - doesn’t matter where you get it from. You can extract it from the ApplicationCall.
if you’re not using JWT, then you probably have to write your own
AuthenticationProvider
(which is not very hard)
a

addamsson

04/25/2020, 9:43 AM
I'm using JWT, but not the one provided by Ktor (i'm using JJWT)
d

Dennis

04/25/2020, 9:51 AM
on the ktor side?
a

addamsson

04/25/2020, 10:21 AM
yep
3 Views