ing-bank / scruid

Scala + Druid: Scruid. A library that allows you to compose queries in Scala, and parse the result back into typesafe classes.
Apache License 2.0
115 stars 29 forks source link

Request Flow Customization (authentication interceptors) #74

Closed barend closed 4 years ago

barend commented 4 years ago

Fixes #66 .

This PR adds an interceptor API for hooking an extension into the HTTP traffic between Scruid and Druid. The API allows the simple case of intercepting the request before its transmission (as implemented by BasicAuthenticationExtension), as well as the complicated case of intercepting the response, reading an authentication challenge, reaching out to some other endpoint to obtain a credential, and finally re-issuing the request.

Implementation notes:

barend commented 4 years ago

I renamed RequestFlowExtension to RequestInterceptor, which I think is a little easier on the eyes. This is slightly inaccurate, because it intercepts not just requests but also responses. However, I think people will figure that out quickly enough when the compiler tells them to implement the interceptResponse method.

mmartina commented 4 years ago

I renamed RequestFlowExtension to RequestInterceptor, ...

There are still some traces of classes named Xxx(flow)Extension. Is that on purpose?

barend commented 4 years ago

There are still some traces of classes named Xxx(flow)Extension. Is that on purpose?

@mmartina No, that was entirely by mistake. I have addressed this.

I have now (also) added the auth config to the documentation.