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

Add support for downloading packages from private sources #8

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

bennettgoble
Copy link
Member

@bennettgoble bennettgoble commented Sep 29, 2022

This changeset provides support for downloading autobuild packages from restricted sources such as private repositories using GitHub release artifacts or GitLab generic packages.

The way this works is by the addition of an optional parameter: creds, which may be specified when adding or editing dependencies:

autobuild installables edit my-pkg creds=github url=...

This property is used to inform autobuild that it should set a HTTP authorization header specific to the provider (github, gitlab) when downloading the respective artifact. An environment variable containing credentials is expected to be set per-provider in order to keep authorization strategies separate:

AUTOBUILD_GITHUB_TOKEN - GitHub Personal Access Token
AUTOBUILD_GITLAB_TOKEN - GitLab Personal Access Token

For example, a GitHub actions runner could do the following:

export AUTOBUILD_GITHUB_TOKEN=$GITHUB_TOKEN
autobuild install

Future

This functionality could be enhanced to include more providers or authorization schemes. The autobuild install command could also be enhanced with equivalent kwargs --github-token and --gitlab-token.

@bennettgoble bennettgoble added the enhancement New feature or request label Sep 29, 2022
This changeset provides support for downloading autobuild packages from
restricted sources such as private repositories using GitHub release
artifacts or GitLab generic packages.

The way this works is by the addition of an optional installable
parameter: `creds`, which may be specified when adding or editing
dependencies:

```
autobuild installables edit my-pkg creds=github url=...
```

This property is used to inform autobuild that it should set a HTTP
authorization header specific to the provider (github, gitlab) when
downloading the respective artifact.

In the future, this could be enhanced to include more providers or
authorization schemes. The `autobuild install` command could also be
enhanced with equivilent kwargs `--github-token` and `--gitlab-token`.
Copy link
Contributor

@brad-linden brad-linden left a comment

Choose a reason for hiding this comment

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

I think my request is beyond the scope for this PR, but would it be a good idea to incorporate use of the python keyring module for handling these kind of credentials in the future?

@bennettgoble
Copy link
Member Author

I think my request is beyond the scope for this PR, but would it be a good idea to incorporate use of the python keyring module for handling these kind of credentials in the future?

Great idea. Yes, I think that should be looked into in the not-too-distant future.

@bennettgoble bennettgoble merged commit 0f2283d into main Sep 29, 2022
@bennettgoble bennettgoble deleted the signal/creds branch September 29, 2022 17:12
except KeyError:
logger.warning(f"Unrecognized creds={creds} value")

token = os.environ.get(token_var)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we use the value of token_var in the same way for both AUTOBUILD_GITHUB_TOKEN and AUTOBUILD_GITLAB_TOKEN, why do we need two separate variables? Acknowledging that we may want different code paths for future kinds of auth tokens, maybe for now just use bearer and AUTOBUILD_BEARER_TOKEN to select this code path that creates an "Authorization: Bearer <token>" header?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want some kind of safety to avoid accidentally leaking github tokens to gitlab and vice versa

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that a real possibility? I'm assuming that mention of gitlab is purely theoretical so far, just because we happen to know that gitlab uses the same "Authorization: Bearer {token}" header.

Copy link
Contributor

Choose a reason for hiding this comment

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

Theoretical for us. Real for third party contributors. I believe gitlab support originated with them in mind.

see also #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants