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

Docs: Add guide for authenticating to Azure Artifacts #4857

Merged
merged 4 commits into from
Jul 15, 2024

Conversation

benjamin-hodgson
Copy link
Contributor

Summary

As discussed in #3542 - there has been some confusion about how to get uv to work with ADO Artifacts so I'm adding a quick guide.

Test Plan

Smoke-tested the examples on my machine.

@benjamin-hodgson
Copy link
Contributor Author

benjamin-hodgson commented Jul 7, 2024

I’ve written the examples using UV_EXTRA_INDEX_URL but of course that’s discouraged because of dependency confusion attacks, lemme know if you think I should change it.

@benjamin-hodgson benjamin-hodgson changed the title Add guide for authenticating to Azure Artifacts Docs: Add guide for authenticating to Azure Artifacts Jul 7, 2024
@zanieb zanieb self-assigned this Jul 7, 2024
@zanieb zanieb added the documentation Improvements or additions to documentation label Jul 7, 2024
export UV_EXTRA_INDEX_URL=https://dummy:[email protected]/{organisation}/{project}/_packaging/{feedName}/pypi/simple/

uv pip install my-private-package
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you should also be able to manually add the PAT into keyring (without the artifacts-keyring plugin) and authenticate transparently with Keyring?

Minus the issues we had in #4056 / #4583

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven’t tested that workflow myself and I don’t know how common it would be (seems to me that you’d either use the plugin, if you have the wherewithal to preinstall stuff, or not use Keyring at all?). I can certainly give it a go tomorrow and add a note if you think it’d be worthwhile. Let me know

```

## Authenticate using Keyring
If you don’t have a PAT handy, you can authenticate to Artifacts using [`keyring`](https://github.com/jaraco/keyring) with [the `artifacts-keyring` plugin](https://github.com/Microsoft/artifacts-keyring). The plugin supports a few different authentication modes including interactive login. Because you’ll be using these two packages to authenticate to Azure Artifacts, you should arrange to have them installed into your environment from a source other than Artifacts.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe what the artifacts-keyring plugin is doing under the hood is creating a PAT and returning it.

Could you confirm that? Do you think it's worth documenting?

Copy link
Contributor Author

@benjamin-hodgson benjamin-hodgson Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The credential provider tool has a few different modes and I don’t know whether all of them wind up creating a PAT behind the scenes. The interactive scenario does seem to.

I wanted to keep this doc relatively short to help people get up and running, but I could link to the repo for the cred-provider so there’s enough of a paper trail for people to learn more, what do you think?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that if the following environment variable is set as follows, a PAT is not created behind the scenes:

NUGET_CREDENTIALPROVIDER_VSTS_TOKENTYPE=SelfDescribing

Here is the relevant help from the credential provider tool (dotnet exec CredentialProvider.Microsoft.dll -h):

Token Type
    NUGET_CREDENTIALPROVIDER_VSTS_TOKENTYPE
        Specify 'Compact' to generate a Personal Access Token, which may
        have a long validity period as it can easily be revoked from the UI,
        and sends a notification mail on creation.
        Specify 'SelfDescribing' to generate a shorter-lived JWT token,
        which does not appear in any UI or notifications
        and is more difficult to revoke.
        By default PATs are generated rather than JWTs,
        unless authentication can be performed non-interactively.

Copy link
Contributor Author

@benjamin-hodgson benjamin-hodgson Jul 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I would prefer to keep this doc as just a high-level getting started guide, I don’t think we should include advanced configuration like that here. I’ve added a link to the cred provider’s GitHub repo in 50f8af6 so people can learn more if they want to.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@zanieb zanieb merged commit a5deb43 into astral-sh:main Jul 15, 2024
39 checks passed
@zanieb zanieb added the preview Experimental behavior label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants