-
Notifications
You must be signed in to change notification settings - Fork 232
Support 3rd-party authentication via bearer token, also other patches #2167
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
Conversation
My current implementation has a known bug. When the server receives a A possible solution is sending a "preflight" request to the 3rd-party server if there is no token, perhaps to |
As you've anticipate that's not going to work. Lots of developers never publish packages. But we could say that if the WWW-Authenticate: Bearer realm="<some message>" Then the client will:
This way servers can put information about how to obtain the authentication token into Side note: I think this would also be in line with how I'm super excited about this PR! But I haven't had time to look through all the code. Don't worry, I'll get back to taking a deeper look. But perhaps we should split this in two PRs. Moving all the URLs for Similarly, when authenticating, we probably look at the URL rather than This also makes sense. It's nice that third parties with their own pub servers can still fetch packages from pub.dev. |
SGTM. I'll first send the PR for moving URL's relative to the hosted URL. Later, I'll send the patch to support auth via third party hosts. In the meantime, I will close this PR. I like the idea of sending a |
Hello! This pull request is an implementation of the features discussed in the issue #1381.
Changes to Existing Functionality
withClient
downloading hosted packages. This allows bearer tokens to be sent to 3rd-party servers when downloading packages. Otherwise, any Pub server would need to make all downloads publicly-accessible, without a token. However, this effectively requires authentication even when downloading frompub.dartlang.org
/pub.dev
. (If this is unacceptable, the logic can be modified to only send a token when using a 3rd-party server, and use the regularhttpClient
.)api/versions/new
,api/packages/:package/uploaders
, andapi/packages/:package/uploaders/:uploader
relative to the$PUB_HOSTED_URL
. In my testing, I noticed that calls topub get
,pub upgrade
,pub global activate
, (basically any command that involved a download) worked fine when the$PUB_HOSTED_URL
included a path, because their implementations append the desired URI to$PUB_HOSTED_URL
(ex.https://foo.com/my/path
->https://foo.com/my/path/api/packages/string_scanner
). However, sincepub uploaders
andpub lish
were usingUri.resolve
with absolute URIs, whatever path was in$PUB_HOSTED_URL
would be obliterated.New Functionality
From the discussion on #1381:
What's Missing
Other
Resolves #1381.