Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(config): option to configure a helper to lookup the token#1359

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 12 commits intopython-gitlab:masterfromklorenz:feat_token_lookup
Apr 18, 2021

Conversation

@klorenz
Copy link
Contributor

@klorenzklorenz commentedMar 6, 2021
edited
Loading

I have stored my personal access token with all other secrets in UNIX password store.
For not having the token stored on the disk, I have implemented the option to let tokens be
looked up from a helper program.

Example:

[my_config]url = https://gitlab.serverprivate_token = helper: ~/bin/pass-helper.shapi_version = 4

whith a helper script~/bin/pass-helper.sh:

#!/bin/bashpass show path/to/token| head -n 1

@klorenzklorenz changed the titleOption to configure a helper to lookup the tokenfeat(config): option to configure a helper to lookup the tokenMar 6, 2021
@nejchnejch self-assigned thisMar 6, 2021
@codecov-io
Copy link

codecov-io commentedMar 6, 2021
edited
Loading

Codecov Report

Merging#1359 (732e49c) intomaster (aa13214) willdecrease coverage by0.23%.
The diff coverage is100.00%.

Impacted file tree graph

@@            Coverage Diff             @@##           master    #1359      +/-   ##==========================================- Coverage   80.21%   79.98%   -0.24%==========================================  Files          73       73                Lines        3801     4021     +220     ==========================================+ Hits         3049     3216     +167- Misses        752      805      +53
FlagCoverage Δ
unit79.98% <100.00%> (-0.24%)⬇️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
gitlab/config.py94.16% <100.00%> (+0.50%)⬆️
gitlab/client.py79.12% <0.00%> (-1.56%)⬇️
gitlab/mixins.py77.92% <0.00%> (-0.94%)⬇️
gitlab/base.py84.66% <0.00%> (+0.42%)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updateaa13214...732e49c. Read thecomment docs.

@klorenz
Copy link
ContributorAuthor

Hi@nejch ,

to fix commitlinting issues, I have squashed my commits and created better commit messages.

Copy link
Member

@nejchnejch left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this feature, this is really really neat :) People have requested native keyring support but I think this might be even more flexible as it can be used with any backend/CLI client like vault etc.

I've just added a few comments, sorry it's just a very user-facing feature so I thought it'd be good to agree on the approach from the start.

Also I think this deserves a mention in the docs, would you mind adding a section inhttps://github.com/python-gitlab/python-gitlab/blob/master/docs/cli-usage.rst?

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@aa13214).Click here to learn what that means.
The diff coverage is86.95%.

Impacted file tree graph

@@            Coverage Diff            @@##             master    #1359   +/-   ##=========================================  Coverage          ?   80.10%           =========================================  Files             ?       73             Lines             ?     4061             Branches          ?        0           =========================================  Hits              ?     3253             Misses            ?      808             Partials          ?        0
FlagCoverage Δ
unit80.10% <86.95%> (?)

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
gitlab/config.py92.61% <86.95%> (ø)

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updateaa13214...91ffb8e. Read thecomment docs.

@klorenz
Copy link
ContributorAuthor

klorenz commentedApr 18, 2021 via email

Hi@nejch, yes I am fine with your changes. This is a good compromisebetween convenience and security. Thanks :)Nejc Habjan ***@***.***> schrieb am So., 18. Apr. 2021, 12:11:
***@***.**** commented on this pull request. ------------------------------ In gitlab/config.py <#1359 (comment)> : > @@ -150,6 +151,16 @@ def __init__( except Exception: pass + for attr in ("job_token", "http_password", "private_token", "oauth_token"): + value = getattr(self, attr) + prefix = "lookup:" + if isinstance(value, str) and value.lower().strip().startswith(prefix): + helper = value[len(prefix) :].strip() + value = ( + subprocess.check_output(helper, shell=True).decode("utf-8").strip() Thank you for the changes@klorenz <https://github.com/klorenz> and sorry for the delay! I'll be merging in a minute. I really liked the convenience of your initial implementation, and I don't want to block this PR any longer so I just pushed a small change (I credited you as the author still) - I went for a compromise where shell=False is still used and recommend wrappers for any scripts that require piping etc. I hope this is ok with you. I also expanded the docs and wrapped the call in a try/except block for people to have a meaningful erorr message on the CLI. See91ffb8e <91ffb8e>, let me know if you want to revisit this in a follow-up. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#1359 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAE2WZADPHXO37LIOFOMXWLTJKV6JANCNFSM4YWO4IXA> .

@nejchnejch merged commitaf781c1 intopython-gitlab:masterApr 18, 2021
@nejchnejch mentioned this pull requestApr 18, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nejchnejchnejch approved these changes

Assignees

@nejchnejch

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@klorenz@codecov-io@codecov-commenter@nejch

[8]ページ先頭

©2009-2025 Movatter.jp