Repository navigation
Conversation
docling-serve has no built-in authentication: it is normally deployed behind a proxy, and the oauth-proxy deployment in its docs authenticates on an Authorization: Bearer header. The client only knew an API key, which it always sends as X-Api-Key, so a deployment behind that proxy could not be used at all. Add a bearerToken option next to apiKey. It is sent as "Authorization: Bearer <token>" on every request, independently of the API key, and it is masked together with the API key when request logging is enabled. The setter goes on the concrete builders only, not on the deprecated DoclingApiBuilder interface, which is documented as not gaining new configuration options and which third-party implementations must keep compiling. As for every option added since that deprecation, LegacyProviderAdapter reports it as unsupported, so a caller going through a legacy factory gets an error naming the factory instead of the token being silently dropped. Signed-off-by: WMK666666 <3496319356@qq.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docling-serve has no built-in authentication: it is normally deployed behind a proxy, and the
oauth-proxydeployment described in its docs authenticates on anAuthorization: Bearerheader.DoclingServeClientonly knows an API key, which it always sends asX-Api-Key, so there was no way totalk to a docling-serve sitting behind that proxy.
Change
DoclingServeApiConfig.BEARER_TOKEN(bearerToken,String), with an accessor on the config and asetter on
DoclingServeApiBuilder.DoclingServeClient.createRequestBuildersends it asAuthorization: Bearer <token>on every request,independently of
apiKey. Both may be set at once, for a proxy that asks for one and docling-serveitself for the other.
Authorizationvalue is masked by the same code that masksX-Api-Keywhen request logging is on.DoclingApiBuilderinterface, which is documented as notgaining new configuration options, so third-party implementations of it keep compiling.
LegacyProviderAdaptertherefore reportsbearerTokenasUnsupported.FAIL: a caller going through alegacy factory gets an error naming the factory, instead of the token being silently dropped.
Tests
DoclingServeClientBearerTokenTests(new, WireMock): the header is sent, it is not sent when no token isconfigured, it is independent of the API key, and
bearerToken(null)unsets the option.DoclingServeApiConfigTestsandAbstractDoclingServeClientConfigTests: the new option is reported bythe config and appears in
explicitlySetOptions(), which keeps the guards that every option has anaccessor and a setter passing.
LegacyProviderAdapterTests:bearerTokenis listed as unsupported for legacy factories../gradlew :docling-serve-api:test :docling-serve-client:testpasses locally, except for the two*ClientTestsclasses that start a docling-serve container, which need Docker and were not run here.Docs
docs/src/doc/docs/docling-serve/serve-client.mdgains anAuthenticationsection covering bothcredentials.