Overview:

ARTIFACTORY: How to use Filtered resource for npm

AuthorFullName__c
Roja R M
articleNumber
000005233
ft:sourceType
Salesforce
FirstPublishedDate
2022-03-29T09:17:07Z
lastModifiedDate
2023-01-22T11:06:09Z
VersionNumber
5
Artifactory can serve the file as a filtered resource on npm repositories and a filtered textual resource is processed by the FreeMarker engine before being returned to clients. The context accessible to the template includes: Properties, Security and Request.

In order to utilize the filtered resource, we would need to follow the below steps

Step 1: Deploy a .npmrc file to any of the npm local repositories available in Artifactory with the following configuration.
_auth = "${security.getEncryptedPassword()!"**** Insert encrypted password here **** "}"
email = "${security.currentUser().getEmail()!"**** Insert EMAIL here **** "}"
always-auth = true

Step 2: Mark this file as a filtered resource in Artifactory

User-added image

Step 3: Try to download the . npmrc file using the cURL command as
$ curl -H "uusername:password" -T ./.npmrc "http://<artifactoryurl>:<port>/artifactory/<repository-name>/.npmrc"

and it is expected to get the file updated “.npmrc” with relevant user details who tried to download the file as shown below. To deploy
.npmrc:<curl command>
Downloaded npmrc after applying filtered resource:
_auth = "xyz"  
email = "xyz@gmail.com"
always-auth = true