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

usage with jfrog artifactory? #138

Open
csulok opened this issue Apr 17, 2020 · 8 comments
Open

usage with jfrog artifactory? #138

csulok opened this issue Apr 17, 2020 · 8 comments

Comments

@csulok
Copy link

@csulok csulok commented Apr 17, 2020

I've been struggling with using this action with my on-premise artifactory instance (to save a release) and it looks like authTokens are not only not supported by it, but it also causes its URL parser to trip. I've tried reproducing what the action is doing in a simple docker image and with the following steps roughly, I get the 404 that leads me to believe artifactory is parsing the :_authToken part wrong.

root@fb783c33d81c:/data# npm config set registry https://internal.service/artifactory/api/npm/npm-release
root@fb783c33d81c:/data# npm config set always-auth true
root@fb783c33d81c:/data# export NODE_AUTH_TOKEN=XXXXX-XXXXX-XXXXX-XXXXX
root@fb783c33d81c:/data# export npm_config__auth=YXJ0aW....qSzJtVw==
root@fb783c33d81c:/data# npm i --ignore-scripts
npm ERR! code E404
npm ERR! 404 Not Found - GET https://internal.service/artifactory/api/npm/npm-snapshot:_authToken=XXXXX-XXXXX-XXXXX-XXXXX/resize-observer-polyfill

Am I doing things wrong here? Is it within the scope of this action / development to support e.g. artifactory? Should I send a pull request that gets rid of auth tokens and allows working with e.g. the basic _auth method?

@bryanmacfarlane
Copy link
Member

@bryanmacfarlane bryanmacfarlane commented Jun 26, 2020

I would recommend creating a community action which is setup-artifactory.

@okuryu
Copy link

@okuryu okuryu commented Jun 30, 2020

Wasn't #48 (always-auth setting) merged for Artifactory?

@bryanmacfarlane
Copy link
Member

@bryanmacfarlane bryanmacfarlane commented Jun 30, 2020

always-auth is an npm specific setting which artifactory happens to need. I think doing things like that is fine. But as soon as the features / concepts / inputs are jfrog / artifactory specific (and I'm not sure what those would be) I think it should be a different setup action.

So I guess that's the next question, what exactly is the ask? Does Artifactory not work with an auth token? A revokable token is better security wise than entering basic credentials for a standing user.

@shawnsparks-work
Copy link

@shawnsparks-work shawnsparks-work commented Jul 1, 2020

I found we need to be able to set registry, _auth, email, and always-auth in npmrc file to work with Artifactory. I believe _auth and email are the two which are missing from this currently.

@Lykathia
Copy link

@Lykathia Lykathia commented Jul 6, 2020

Does Artifactory not work with an auth token

It does not, unfortunately. It does provide both user credential and access token (their own) support for builds using _auth instead of authToken.

My .npmrc's don't contain email, and work with just the following:

_auth = XXXXXXXXXXX
always-auth = true
registry = ...

The way we've generally implemented this for usage in docker development environments and the like is to set the environment variables NPM_CONFIG__AUTH and NPM_ALWAYS_AUTH instead of mucking with the .npmrc file directly.

EDIT: Just verified that this works w/ artifactory. (.npmrc file is checked into the repo w/ the registry key set, but it could also be set via ENV here to bypass the auth setup check for setup-node)


jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
      - name: Use Node.js
        uses: actions/setup-node@v1
        with:
          node-version: '14.x'
      - name: Cache Node.js modules
        uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.OS }}-node-
            ${{ runner.OS }}-
      - name: Install dependencies
        run: npm ci
    env:
      NPM_CONFIG__AUTH: ${{ secrets.ARTIFACTORY_ACCESS_KEY }}
      NPM_ALWAYS_AUTH: true

@aripanyvision
Copy link

@aripanyvision aripanyvision commented Jul 30, 2020

Anyone got setup-node to work with JFROG npm private repo? cant seem to get the authentication going correctly here

@lub0v-parsable
Copy link

@lub0v-parsable lub0v-parsable commented Sep 14, 2020

I couldn't make @Lykathia's setup to work, so as a workaround, I had to create .npmrc "manually" before calling the actions/setup-node@v1

steps:
  - name: 'Checkout'
    uses: actions/checkout@v2

  - name: 'Create .npmrc'
    shell: bash
    run: |
      echo "registry=https://company.jfrog.io/artifactory/api/npm/npm-registry-name/" > .npmrc
      echo "_auth = ${{ secrets.JFROG_NPM_AUTH_TOKEN }}" >> .npmrc
      echo "always-auth = true" >> .npmrc

  - name: Use Node.js
    uses: actions/setup-node@v1
    with:
       node-version: '10.14.0'

make sure to remove the registry-url from the actions/setup-node@v1 because otherwise it will override the .npmrc.

@SpencerKaiser
Copy link

@SpencerKaiser SpencerKaiser commented Nov 11, 2020

@lub0v-parsable you're awesome! 🎉 You just ended a multi-hour search to get this working. @Lykathia's suggestion looks awesome (and I'd love to see that implemented one day), but it throws a warning saying those fields aren't supported.

At my company we encode some attributes as part of our token, so I had to wrap the _auth bit in another set of quotes (e.g., echo "_auth = \"something that might have spaces\"" >> .npmrc) in case anyone has to do something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.