-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Private registry: Fetching packages not possible #4672
Comments
This was unrelated, nevermind. |
This is a real showstopper for us. We've just changed all our private dependencies from Gitlab ssh links ( I downgraded to 0.28.4. and everything works fine. Seems like
in 0.28.4 works totally fine while in 1.2.x (and 1.3.2) it throws an error:
Is that by intention because support for npmrc authTokens has been dropped or is it a regression bug? Is there a workaround for that? |
@manuelbieh
|
Awesome, thanks! |
This is because the new Please, maintainers, don't try to be clever here. The mental contract is that when I This is, as @manuelbieh mentioned, somewhat of a showstopper for us. EDIT: Went in to make a PR, which unsurprisingly is a lot more involved than I had hoped. Yarn doesn't appear to be storing the NPM token at all (correct me if I'm wrong) - unless you've used As it's written now, there is no way to use scoped private packages in Yarn without adding a If anyone wants to deep-dive into this, here's a great place to start: diff --git a/src/cli/commands/login.js b/src/cli/commands/login.js
index f252397..8ca5ef0 100644
--- a/src/cli/commands/login.js
+++ b/src/cli/commands/login.js
@@ -113,5 +113,5 @@ export function hasWrapper(commander: Object, args: Array<string>): boolean {
export function setFlags(commander: Object) {}
export async function run(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {
- await getCredentials(config, reporter);
+ await getToken(config, reporter);
} That will prompt for the username/email, as well as the password. However, it'll do that each time to run This is indeed a major showstopper for us. At this time, we cannot use Yarn as a replacement for NPM. |
This thread is amazing with how much insight you all provided, thank you so much. Especially @Qix- and @ptusch. I'd love to get this fixed since it has been an ongoing issue for some time now. The problem is, it is not easy to reproduce, especially when private registries are involved. @Qix- from your last message, I understand that your expectation is for Yarn to prompt for a username and a password when it detects a private package. You also mention it is hard to detect this since NPM returns a 404 response for private packages without credentials provided to prevent information leak. I know that Yarn is geared towards minimal user interaction after a command started and I do not think we can pause the resolution process to prompt for user input. I understand that putting credentials in a config file is not ideal but we should also be supporting environment variables for this. Would that be a good solution? Also, the reason we are trying to be smart is to protect your credentials. We do not want to send your credentials to Yarn's registry or say, to GitHub or to any custom URL that is passed in the version unless you explicitly set @ptusch - I really appreciate the detailed instructions on how to reproduce the issue. Do you think we can construct a Dockerfile that has all the steps codified so someone can just pul it and run it with the private registry set up as the way you mentioned so the only remaining part is running a command or script that demonstrates the issue? If you think so I'll give that a shot and see how far I can get. Any guidance regarding the actual set up in terms of code or commands would be greatly appreciated to speed up the process. |
@BYK using the npm registry solves this issue for me, and others, in any yarn version. |
Sure, that solves some of the problem - namely in the case where we would want to avoid creating an actual However, in the case where I want to completely replace From there, getting it into an environment variable would probably require outputting to stdout, no? Something like Thank you for prioritizing this <3 It's really appreciated. EDIT: To be clear, it'd be awesome if we could avoid storing the token somehow. I'm not sure how that would look, though, without having to re-authenticate each time. |
@BYK Hey,
I'm not sure if I can setup an artifactory in a Dockercontainer but I'm sure something like sinopia or verdaccio will do just as fine. Just give me a day or so and I'll prove one (I'm a huge docker noob so please be patient).
I'd also appreciate this approach. I think npm supports all config elements setable in Thanks for taking care ❤️ |
@BYK Alrighty, I think I was able to create a nice docker image for you. You'll find two packages containing a sample for each, installing and publishing so you can see that publishing is find but installing fails. Btw. this isn't a 100% reconstruction. I didn't set up SSL for verdaccio but I'm sure it will do just as well. I can always test against our private repository in case of needed test (say when this one works). Anyway, I hope this will be of great service. Edit: |
@ptusch can you paste the dockerfile here? :) |
Woops, totally forgot. Its shamelessly stolen from verdaccio and slightly modified. But please keep in mind you'd still need to manually register someone and publish the package (the register part is interactive so no static fun). Or do you need a Dockerfile on top on my image to simply execute the thing? The Dockerfile I used to create the image: FROM node:8.9.0-alpine
LABEL maintainer="https://github.com/verdaccio/verdaccio"
RUN apk --no-cache add openssl && \
wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \
chmod +x /usr/local/bin/dumb-init && \
apk del openssl
ENV APPDIR /usr/local/app
WORKDIR $APPDIR
ENV NODE_ENV=production
ENV npm_config_prefix=${APPDIR}
RUN npm config set registry http://registry.npmjs.org/ && \
npm install [email protected] -g
RUN mkdir -p /verdaccio/storage /verdaccio/conf
ADD config.yaml /verdaccio/conf/config.yaml
RUN addgroup -S verdaccio && adduser -S -G verdaccio verdaccio && \
chown -R verdaccio:verdaccio "$APPDIR" && \
chown -R verdaccio:verdaccio /verdaccio
USER verdaccio
ENV PORT 4873
ENV PROTOCOL http
EXPOSE $PORT
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
CMD $APPDIR/bin/verdaccio --config /verdaccio/conf/config.yaml --listen $PROTOCOL://0.0.0.0:${PORT} The modified config (only authenticated can access): storage: /verdaccio/storage
auth:
htpasswd:
file: /verdaccio/conf/htpasswd
# Maximum amount of users allowed to register, defaults to "+infinity".
# You can set this to -1 to disable registration.
#max_users: 1000
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
# scoped packages
access: $authenticated
publish: $authenticated
proxy: npmjs
'**':
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $authenticated
# allow all known users to publish packages
# (anyone can register by default, remember?)
publish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs
# log settings
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: verdaccio.log, level: info} |
This is amazing! Thanks a lot for putting this together in such a short time and sorry for not responding earlier. I'll use these to dig into the issue and write back here about what I find. Thanks again! PS: If anyone is curious to try and see themselves, don't get discouraged because I said I'll look into this. The aim is to fix this problem ASAP, not specifically me to fix this problem :) |
Probably not related; but I had this 404 issue on windows - even after logging into npm. I suspect the old-credientials where still being used (somehow) by yarn, while npm worked perfectly fine. I cleared my .npmrc and .yarnrc completely from my user-directory. Then did a fresh log-in to npm. yarn started working again with private repositories. |
So just hit a bug the other day where some tokens aren't accepted by NPM even though NPM spit them back out at me - ultimately causing a 404. Not entirely sure how NPM implements token generation but they seem to be inconsistent in how they handle them. Just a thought. |
@MeirionHughes we may wanna start ignoring old auth fields. @arcanis @bestander thoughts? |
I am currently experiencing this issue with the latest yarn version. I have my auth token and everything in my .npmrc (I have no .yarnrc) and it worked correctly in [email protected] but it fails now. My private registry is on an Artifactory server. Yarn seems to not use the auth token at all because it gives an HTTP 401 error. Downgrading to 0.27.5 works for me. .npmrc:
Error:
|
Related: #4451 |
@valscion Thanks, a colleague actually told me something similar the other week.. |
@valscion GitHub doesn't support commas - you need separate lines now each with "fixes". I think they supported it once but they don't anymore. |
So small update; Seems like it works. It's worth noting though that it requires a working When the password/token is not present in the .npmrc, the installation will fail with nothing to help:
So perhaps, we'd like to have an interactive login, just like npm has. |
Sounds like a new issue to me? |
I agree. But it's not just the interactive "ness" but also storing that information which might cause discussions since yarn didn't seem to persist that information. |
Still, seems like this issue is solved and a new one should be opened in case there's more things to address? EDIT: Oh wait, sorry, just re-read the issue description. Yeah. This might be a good issue for this workflow problem, but maybe the title should be improved? |
Had issues with |
@mhumeSF thanks... i was bout to give up on yarn. |
Fetching packages from a private registry is still not possible for me. There are a number of related issues but I can't find a clear description in the documentation of how to setup private registries. I have the same registry working with npm, but when I try yarn install I get:
I've tried to add Could someone document how to configure this? Update for clarity, I'm not asking how to setup a private registry server, I'm looking for documentation for yarn that says yes private registries are supported and here is how to configure yarn to access your private registry. I'm specifically targeting Gitlab, if that matters. |
@stevehawley There's a Dockerfile a few comments above you: #4672 (comment) |
Any update here from the yarn team? |
Having same problem here - |
Hey folks, |
Am I understanding it correctly? With that fix in place (#5216) Yarn respects auth token but it is only working when you already have auth token present in the rc file all while you can't get auth token to appear there through normal means by using Yarn? People in the other issue (#6405) suggest using npm for authorization, which is rather ridiculous.
How about adding |
As of today, it still doesn't work for us. In my opinion it's really a bug of Although I full adhere to @BYK's point of view regarding credentials privacy, the only solution that worked for us was to use |
You can also see the same auth problem with "yarn install" on existing projects. It fails to send (or prompt for) auth in the GET phase for "public" packages accessed via a private caching server. (even if user+password is in the URL) Perhaps this thread chould be linked to an outstanding enhancement issue (I did not find one)?
The only thing that works is what wassafr describes: npm login + always-auth true. Now that I have spent hours figuring it out, I have to agree that /in theory/ this auth process is entirely logical. But, TBH fairly byzantine (obscure? apocryphal?) from a "how do I use this tool in real life" perspective. Which clashes strongly with the rest of yarn's awesomeness, and therefore I think qualifies it as a needed UX enhancement (not a bug). So I mostly that this bug report should stay closed, but possibly a new issue/enhancement is needed as this was not a pleasant experience. |
Came here with the same issue on a private Verdaccio registry, none of this solved it. Found a solution and wrote it up here: #6405 (comment) Basically, make sure that no auth token for |
Versions
[email protected]
[email protected]
Linux (arch) x86_64
Do you want to request a feature or report a bug?
Bug
- or -missing feature
What is the current behavior?
yarn add PRIVATE_PACKAGE
does not work - I'm never authenticated(this happens with a freshly set-up
~/.yarnrc
with not pre existing~/.npmrc
)If the current behavior is a bug, please provide the steps to reproduce.
yarn config set registry https://my_cool_artifactory/api/npm/cool_npm_repository
yarn add PRIVATE_PACKAGE
What is the expected behavior?
I suppose I should get the package.
After I set up the repository and a 4xx error is returned, I expect a CLI query asking for my username, email and password (drop the username and email when those are already entered in
~/.yarnrc
)More descriptive stuff
Okay, we have an artifactory server which serves as both, a proxy and a private repository container.
There is no anonymous access to the server so even read access is bound to a proper log in.
I started from scratch with no pre existing .npmrc.
I created my
~/.yarnrc
by doing this:yarn config set registry https://my_artifactory/and/its/repo
yarn config set always-auth true
yarn config set strict-ssl true
yarn config set cafile /path/to/root/cert
After this set up I invoked
yarn login
and entered my username and email.Publishing a package is no problem since I'm asked for my password here.
The workflow for the publishing seems to be
After this, I'm left as I started - without a token since it was deleted (and it was probably in the RAM anyway).
When I then invoke
yarn add
to add my private package, I'm not queried for my password which results is a 403 (Forbidden). Yarn doesn't evaluate this issue and merely reports it back to me.I didn't find a way to set a proper auth token. I played a bit with postman and was able to create a valid token for myself but not sure how I'd use it after this (maybe there is a hidden CLI flag?).
This seems to be the wrong way anyway. Manually grabbing a token to make the package manager work sounds counter intuitive to me.
Looking into other threads didn't help either. Most "solutions" seem to be work arounds.
The only solution that seemed to work was to put my plain credentials into the
~/.npmrc
and work with that. But that only worked for a direct private package with no private packages as dependencies there. I suppose the credentials are stripped from the URL after the first iterationThis also happened another day while testing with a second
~/.npmrc
I guess I'll try to add the token I created with postman in the
~/.npmrc
manner and add it like //MY_REGISTRY:TOKENAnyway, I hope this is any helpful and maybe someone can help me out.
Cheers
Edit: Adding the token to the
~/.yarnrc
Didn't help either.The text was updated successfully, but these errors were encountered: