diff --git a/src/main/java/jenkins/plugins/nodejs/NodeJSConstants.java b/src/main/java/jenkins/plugins/nodejs/NodeJSConstants.java index e51aa86..71edb0d 100644 --- a/src/main/java/jenkins/plugins/nodejs/NodeJSConstants.java +++ b/src/main/java/jenkins/plugins/nodejs/NodeJSConstants.java @@ -65,15 +65,6 @@ private NodeJSConstants() { */ public static final String NPM_USERCONFIG = "npm_config_userconfig"; - /** - * Force npm to always require authentication when accessing the registry, - * even for GET requests. - *

- * Default: false
- * Type: Boolean - *

- */ - public static final String NPM_SETTINGS_ALWAYS_AUTH = "always-auth"; /** * The base URL of the npm package registry. *

diff --git a/src/main/java/jenkins/plugins/nodejs/configfiles/RegistryHelper.java b/src/main/java/jenkins/plugins/nodejs/configfiles/RegistryHelper.java index 75002e6..ae993a4 100644 --- a/src/main/java/jenkins/plugins/nodejs/configfiles/RegistryHelper.java +++ b/src/main/java/jenkins/plugins/nodejs/configfiles/RegistryHelper.java @@ -23,7 +23,6 @@ */ package jenkins.plugins.nodejs.configfiles; -import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_ALWAYS_AUTH; import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_AUTH; import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_AUTHTOKEN; import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_PASSWORD; @@ -143,8 +142,6 @@ public String fillRegistry(String npmrcContent, Map // add scoped values to the user config file npmrc.set(compose('@' + scope, NPM_SETTINGS_REGISTRY), registryURL); if (credentials != null) { // NOSONAR - npmrc.set(compose(registryPrefix, NPM_SETTINGS_ALWAYS_AUTH), credentials != null); - // the _auth directive seems not be considered for scoped registry // only authToken or username/password works if (credentials instanceof UsernamePasswordCredentials) { @@ -165,7 +162,6 @@ public String fillRegistry(String npmrcContent, Map // add values to the user config file npmrc.set(NPM_SETTINGS_REGISTRY, registry.getUrl()); if (credentials != null) { - npmrc.set(compose(registryPrefix, NPM_SETTINGS_ALWAYS_AUTH), credentials != null); if (credentials instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials usernamePassowrd = (UsernamePasswordCredentials) credentials; String authValue = usernamePassowrd.getUsername() + ':' + Secret.toString(usernamePassowrd.getPassword()); diff --git a/src/test/java/jenkins/plugins/nodejs/configfiles/RegistryHelperCredentialsTest.java b/src/test/java/jenkins/plugins/nodejs/configfiles/RegistryHelperCredentialsTest.java index 3a928dd..03b521e 100644 --- a/src/test/java/jenkins/plugins/nodejs/configfiles/RegistryHelperCredentialsTest.java +++ b/src/test/java/jenkins/plugins/nodejs/configfiles/RegistryHelperCredentialsTest.java @@ -23,7 +23,6 @@ */ package jenkins.plugins.nodejs.configfiles; -import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_ALWAYS_AUTH; import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_AUTH; import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_PASSWORD; import static jenkins.plugins.nodejs.NodeJSConstants.NPM_SETTINGS_REGISTRY; @@ -116,7 +115,6 @@ private void verifyScopedRegistry(RegistryHelper helper, Npmrc npmrc, NPMRegistr String registryPrefix = helper.calculatePrefix(registry.getUrl()); // scoped registry not depends on npm format, has always the registry prefix - String alwaysAuthKey = helper.compose(registryPrefix, NPM_SETTINGS_ALWAYS_AUTH); String usernameKey = helper.compose(registryPrefix, NPM_SETTINGS_USER); String passwordKey = helper.compose(registryPrefix, NPM_SETTINGS_PASSWORD); @@ -124,10 +122,6 @@ private void verifyScopedRegistry(RegistryHelper helper, Npmrc npmrc, NPMRegistr assertThat(npmrc.contains(helper.compose(registryPrefix, NPM_SETTINGS_AUTH))).as("Unexpected value for " + NPM_SETTINGS_AUTH).isFalse(); if (registry.getCredentialsId() != null) { - // test require authentication, by default is false - assertThat(npmrc.contains(alwaysAuthKey)).as("key %s not found", NPM_SETTINGS_ALWAYS_AUTH).isTrue(); - assertThat(npmrc.getAsBoolean(alwaysAuthKey)).isTrue(); - // test credentials fields assertThat(npmrc.get(usernameKey)).isEqualTo(user.getUsername()); String password = npmrc.get(passwordKey); @@ -146,12 +140,8 @@ private void verifyScopedRegistry(RegistryHelper helper, Npmrc npmrc, NPMRegistr private void verifyGlobalRegistry(RegistryHelper helper, NPMRegistry registry, Npmrc npmrc, boolean npm9Format) { String registryPrefix = helper.calculatePrefix(registry.getUrl()); - String alwaysAuthKey = npm9Format ? helper.compose(registryPrefix, NPM_SETTINGS_ALWAYS_AUTH) : NPM_SETTINGS_ALWAYS_AUTH; String authKey = npm9Format ? helper.compose(registryPrefix, NPM_SETTINGS_AUTH) : NPM_SETTINGS_AUTH; - assertThat(npmrc.contains(alwaysAuthKey)).as("Unexpected value for %s", alwaysAuthKey).isEqualTo(registry.getCredentialsId() != null) // - ; - if (registry.getCredentialsId() != null) { // test _auth String auth = npmrc.get(authKey);