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

Allow Authentication via Http Header #1042

Closed
MichaelCkr opened this issue Jul 15, 2022 · 4 comments
Closed

Allow Authentication via Http Header #1042

MichaelCkr opened this issue Jul 15, 2022 · 4 comments

Comments

@MichaelCkr
Copy link

MichaelCkr commented Jul 15, 2022

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

Authentication for downloading npm and node (goal install-node-and-npm) is only possible via username and password. In a CI pipeline one may usually use a token, which needs a authentication via an http header.

See coding in com.github.eirslett.maven.plugins.frontend.lib.DefaultFileDownloader#execute.

What is the expected behavior?

I'd like to use kind of following server configuration in my maven settings

<server>
   <id>gitlab</id>
   <configuration>
      <httpHeaders>
         <property>
            <name>Job-Token</name>
            <value>${env.CI_JOB_TOKEN}</value>
         </property>
      </httpHeaders>
   </configuration>
</server>

with the server id configured in the plugin configuration.

E.g. gitlab added the opportunity to use the CI_JOB_TOKEN for authentication with an http header, see issue 30650 here. Using a token like this, allow to drop any configured token, because it is created for every pipeline individually. Using a job token with a username und password authentication unfortunately is not possible.

Please mention your frontend-maven-plugin and operating system version.

  • frontend-maven-plugin in version 1.12.1
  • OS: Debian GNU/Linux 10 (buster)
@aixigo-soffermann
Copy link

Are there any plans on fixing this?

liefke added a commit to liefke/frontend-maven-plugin that referenced this issue Sep 3, 2024
@eirslett
Copy link
Owner

eirslett commented Sep 4, 2024

It looks like this isn't supported by Maven:
https://maven.apache.org/settings.html#servers

According to the documentation, it seems like Maven only supports basic authentication or SSH keys.
I'm very reluctant to add custom authentication mechanisms that are not part of Maven officially. Is it possible to send the CI token as <password> instead in maven, instead of as a header?
I mean, you're already using the same Maven artifactory for downloading your jar dependencies, so it should be working already, right?

liefke added a commit to liefke/frontend-maven-plugin that referenced this issue Sep 4, 2024
@liefke
Copy link
Contributor

liefke commented Sep 4, 2024

@eirslett: Thank you for taking your time to look into this.

This is indeed supported by Maven, the configuration section is left empty in your documentation page, but there is another one: https://maven.apache.org/guides/mini/guide-http-settings.html#http-headers

So the example <server> section from above is working for other dependency downloads in Maven, for example when running against Artifactory as repository server (which would not accept the token as HTTP-Auth password).

I had a small bug in my pull request from yesterday, but with the latest commit the HTTP-Header authentication is working as expected.

@liefke
Copy link
Contributor

liefke commented Sep 4, 2024

I just recognized that my documentation link from above is outdated since Maven 3.9.0, but the following page is telling the same about HTTP headers: https://maven.apache.org/guides/mini/guide-resolver-transport.html#custom-http-headers

eirslett pushed a commit that referenced this issue Sep 5, 2024
@eirslett eirslett closed this as completed Sep 5, 2024
atl-mk pushed a commit to atlassian-forks/frontend-maven-plugin that referenced this issue Sep 19, 2024
atl-mk pushed a commit to atlassian-forks/frontend-maven-plugin that referenced this issue Sep 19, 2024
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

4 participants