https://kotlinlang.org logo
#http4k
Title
# http4k
d

dave

02/27/2021, 7:06 PM
Sure. PR away! 😉
r

Razvan

02/27/2021, 7:40 PM
You don’t see any possible problems with Contracts ?
Copy code
security = BearerAuthSecurity(key = credentials, ::mapVerification)
d

dave

02/27/2021, 7:43 PM
Don't think so. Try it and see if the tests still pass! 😂
r

Razvan

02/28/2021, 5:29 PM
Tests still pass (well not
JettyHttp2Test
that fails with-
No Server ALPNProcessors!
, but I don’t think is related, looks like arm jdk linked error) as I tried to look for tests concerning BearerAuthSecurity and couldn’t find guess there are some not unit ones somewhere. There’s still a drawback, as the generic is set at the class level that requires to pass a class when you use others constructors. So there are some places like
ContractRendererContract
where it was:
security = BearerAuthSecurity("foo")
but now has to be
security = BearerAuthSecurity<Any>("foo")
can’t think of how this could be avoided, but if you do, I’d be happy to learn. But if there’s none I’m not sure is clean to require to pass a class when you don’t use it. There’s also the possibility to make a separate class for just the constructor with the ContextLens:
Copy code
class BearerAuthSecurityContext<T> private constructor(override val filter: Filter, val name: String = "bearerAuth") : Security {
    constructor(key: RequestContextLens<T>, lookup: (String) -> T?, name: String = "bearerAuth") : this(ServerFilters.BearerAuth(key, lookup), name)
    
    companion object
}
but I’m not the lib designer not sure what option is better.