Send password from basic auth as header

Hi, I have ServiceA which can send BasicAuth requests to other services. But ServiceB needs a specific header to authorize (for example PRIVATE-TOKEN: ). I would like to configure Traefik, that it listens for ServiceA requests, gets the from the BasicAuth (ignore username) and adds the value as PRIVATE-TOKEN header to the request. After this, redirect the request to ServiceB.

In the documentation I cant find a way to do this. Is there a way to configure Traefik to the behaviour?

Thanks so much in advance.

Hi @wandi34,

Thanks for your interest in Traefik.

Did you have a look at the BasicAuth and ForwardAuth middlewares?

Maxence

Hi @moutoum,

thanks for your reply. Yes, I already took a look on this middlewares. But as far as I see:

  • BasicAuth is just possible to authenticate the sent credentials against a file or store the credentials as a seperate header field. But I dont want to store the Basic auth credentials as seperate header. I just want to save a part of the auth header (password) as seperate Header
  • FordwardAuth is just possible to sent the auth request to a seperate auth service and check if the request is allowed to be passed through.

Am I missing something?

Ok, I misunderstood your use case.
No, we don't have such middlewares.
You can try to look at the Traefik Plugins and create one for your case. We are working on them actually and pilot is not needed anymore. The documentation is not fully updated, and some PRs are open in these regards.

Thanks,
Maxence

Nice. Custom plugins sound nice for my needs. I would like to give it a try. I have read the documentation about plugins but cant find a doc howto include the plugin into my traefik (started as docker).

As you said "Pilot is not needed anymore". Whats the way you suggest? Any doc?

Thanks for your help

Hi @wandi34,

There is a documentation on how to develop, test and deploy a custom plugin. You'll have to create a repository on github with some configuration and a bot will fetch it to include it in a catalog from which traefik will load it.

Let me know if you have more questions about it.

Thanks,
Maxence

Jeah I already read that documentation. But you said I dont need Traefik Pilot to get the plugin work in my traefik instance. In the documentation is only written how to connect it via Traefik Pilot. Maybe the reasen is as you said, that its unfortunately bit deprecated.

But how does it then work to include the plugin into Traefik without the Pilot?

Hi @wandi34,

Plugins are working exactly in the same way as before, but you just have to remove the pilot entry from your configuration which is not used anymore.
You can use the local plugins: GitHub - traefik/plugindemo: A Traefik demo plugin. which should work for you for developing, testing and prod.

Maxence