Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Authorization token type should be case insensitive #890

Closed
huzaus opened this issue Dec 17, 2020 · 1 comment
Closed

[BUG] Authorization token type should be case insensitive #890

huzaus opened this issue Dec 17, 2020 · 1 comment

Comments

@huzaus
Copy link

huzaus commented Dec 17, 2020

Tapir version: 0.17.0-M3

Scala version: 2.12.10

What is the problem?

Getting exception below for authorization token type which starts from lower case token type b: --header 'Authorization: bearer xxxxx'.
According to spec it should be case insensitive https://tools.ietf.org/html/rfc6749#section-5.1 :

token_type
REQUIRED. The type of the token issued as described in
Section 7.1. Value is case insensitive.

java.lang.IllegalArgumentException: The given value doesn't start with Bearer
at sttp.tapir.Mapping$.removePrefix$1(Mapping.scala:96) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping$.$anonfun$stringPrefix$1(Mapping.scala:97) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping$$anon$4.rawDecode(Mapping.scala:84) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.$anonfun$rawDecode$1(Codec.scala:56) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.DecodeResult$Value.flatMap(DecodeResult.scala:15) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.rawDecode(Codec.scala:56) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.$anonfun$tryRawDecode$1(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at scala.util.Try$.apply(Try.scala:213) ~[org.scala-lang.scala-library-2.12.10.jar:na]
at sttp.tapir.Mapping.tryRawDecode(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode$(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.decode(Codec.scala:55) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$.$anonfun$listNoMeta$2(Codec.scala:361) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at scala.collection.immutable.List.map(List.scala:286) ~[org.scala-lang.scala-library-2.12.10.jar:na]
at sttp.tapir.Codec$.$anonfun$listNoMeta$1(Codec.scala:361) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping$$anon$4.rawDecode(Mapping.scala:84) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.$anonfun$rawDecode$1(Codec.scala:56) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.DecodeResult$Value.flatMap(DecodeResult.scala:15) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.rawDecode(Codec.scala:56) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.$anonfun$tryRawDecode$1(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at scala.util.Try$.apply(Try.scala:213) ~[org.scala-lang.scala-library-2.12.10.jar:na]
at sttp.tapir.Mapping.tryRawDecode(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode$(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.decode(Codec.scala:55) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$2.rawDecode(Codec.scala:68) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.$anonfun$tryRawDecode$1(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at scala.util.Try$.apply(Try.scala:213) ~[org.scala-lang.scala-library-2.12.10.jar:na]
at sttp.tapir.Mapping.tryRawDecode(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode$(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$2.decode(Codec.scala:67) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$4.rawDecode(Codec.scala:92) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.rawDecode(Codec.scala:56) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.$anonfun$tryRawDecode$1(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at scala.util.Try$.apply(Try.scala:213) ~[org.scala-lang.scala-library-2.12.10.jar:na]
at sttp.tapir.Mapping.tryRawDecode(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode$(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$1.decode(Codec.scala:55) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$2.rawDecode(Codec.scala:68) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.$anonfun$tryRawDecode$1(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at scala.util.Try$.apply(Try.scala:213) ~[org.scala-lang.scala-library-2.12.10.jar:na]
at sttp.tapir.Mapping.tryRawDecode(Mapping.scala:31) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Mapping.decode$(Mapping.scala:28) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.Codec$$anon$2.decode(Codec.scala:67) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.internal.DecodeInputs$.matchOther(DecodeInputs.scala:252) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.internal.DecodeInputs$.matchOthers(DecodeInputs.scala:211) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.internal.DecodeInputs$.$anonfun$apply$7(DecodeInputs.scala:81) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.internal.DecodeInputs$.$anonfun$compose$1(DecodeInputs.scala:289) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.internal.DecodeInputs$.$anonfun$compose$1(DecodeInputs.scala:290) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.internal.DecodeInputs$.$anonfun$compose$1(DecodeInputs.scala:290) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.internal.DecodeInputs$.apply(DecodeInputs.scala:82) ~[com.softwaremill.sttp.tapir.tapir-core_2.12-0.17.0-M3.jar:0.17.0-M3]
at sttp.tapir.server.http4s.EndpointToHttp4sServer.$anonfun$toHttp$4(EndpointToHttp4sServer.scala:53) ~[com.softwaremill.sttp.tapir.tapir-http4s-server_2.12-0.17.0-M3.jar:0.17.0-M3]
at cats.data.KleisliSemigroupK.$anonfun$combineK$1(Kleisli.scala:556) ~[org.typelevel.cats-core_2.12-2.2.0.jar:2.2.0]
at cats.data.KleisliSemigroupK.$anonfun$combineK$1(Kleisli.scala:556) ~[org.typelevel.cats-core_2.12-2.2.0.jar:2.2.0]
at cats.data.KleisliSemigroupK.$anonfun$combineK$1(Kleisli.scala:556) ~[org.typelevel.cats-core_2.12-2.2.0.jar:2.2.0]
at cats.data.KleisliSemigroupK.$anonfun$combineK$1(Kleisli.scala:556) ~[org.typelevel.cats-core_2.12-2.2.0.jar:2.2.0]
at cats.data.KleisliSemigroupK.$anonfun$combineK$1(Kleisli.scala:556) ~[org.typelevel.cats-core_2.12-2.2.0.jar:2.2.0]
at cats.data.KleisliSemigroupK.$anonfun$combineK$1(Kleisli.scala:556) ~[org.typelevel.cats-core_2.12-2.2.0.jar:2.2.0]
at org.http4s.syntax.KleisliResponseOps.$anonfun$orNotFound$1(KleisliSyntax.scala:38) ~[org.http4s.http4s-core_2.12-0.21.8.jar:0.21.8]
at org.http4s.server.blaze.Http1ServerStage.$anonfun$raceTimeout$1(Http1ServerStage.scala:340) ~[org.http4s.http4s-blaze-server_2.12-0.21.8.jar:0.21.8]
at org.http4s.server.blaze.Http1ServerStage$$anon$2.$anonfun$run$1(Http1ServerStage.scala:183) ~[org.http4s.http4s-blaze-server_2.12-0.21.8.jar:0.21.8]
at zio.ZIO$.$anonfun$effectSuspend$1(ZIO.scala:2631) ~[dev.zio.zio_2.12-1.0.3.jar:1.0.3]
at zio.internal.FiberContext.liftedTree1$1(FiberContext.scala:571) [dev.zio.zio_2.12-1.0.3.jar:1.0.3]
at zio.internal.FiberContext.evaluateNow(FiberContext.scala:571) [dev.zio.zio_2.12-1.0.3.jar:1.0.3]
at zio.internal.FiberContext.$anonfun$fork$17(FiberContext.scala:772) [dev.zio.zio_2.12-1.0.3.jar:1.0.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_252]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_252]

How to reproduce?

Use TapirAuth.bearer[String] for endpoint send request with --header 'Authorization: bearer xxxxx'

Additional information

@huzaus huzaus changed the title [BUG] [BUG] Authorization token type should be case insensitive Dec 17, 2020
@adamw adamw closed this as completed in 43bd2c0 Dec 21, 2020
@adamw
Copy link
Member

adamw commented Dec 22, 2020

Fixed in 0.17.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants