-
Notifications
You must be signed in to change notification settings - Fork 902
use user/pass flags #254
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
use user/pass flags #254
Conversation
b005861 to
0080512
Compare
|
I am not really thrilled with the generic option names: if I am worried that we really shouldn’t send the same password to several different servers. OTOH the distinction really isn’t between transport types, but between individual hostnames, and that would be a horrible UI, so a generic This should also restore After that, I guess, LGTM. |
|
(As for “we already do use generic option names for Docker-specific options”, that's partly legacy. And partly using |
Sort of.. I have to mock an empty Docker cfg first. I'll add that though, thx.
We used to have user/pass flag in the very first skopeo versions :/ |
|
Yeah; I am not thrilled with |
|
@mtrmac what if we add |
|
That’s great idea. We can very confidently expect that the sets of servers underlying a transport( Yes to |
|
Alright, do note that I'll make these new flags available only to |
|
Or wait, I can add username and password flag locally for inspect/layers commands. I'll do this way. |
0080512 to
dda3750
Compare
|
@mtrmac PTAL, before going ahead and add docs/tests/ |
dda3750 to
f786369
Compare
|
I don't like options with dashes ("-") in them. Could we look at other tools like ssh? Would be better? |
|
@rhatdan fine, but |
|
We don't need to specify the registry also, that's implied by src and dest in the command and we don't need that (something like that is how the Docker auth config file works but that's another story, here in the cli we directly honor user/pass combination without checking the registry they'll be used to authenticate against) |
|
@runcom It would help me if you gave a couple of examples of what you are proposing for a CLI. |
|
Like |
|
I like that better |
That feels a bit off, as a general security habit I like to avoid formatting/parsing and in-band signalling. More importantly, it may make sense to provide an username but not a password (e.g. when authenticating using a Kerberos ticket, or a smartcard) |
alright, no parsing then, any idea regarding Dan's issue on naming? |
|
Why wouldn't --cred dwalsh I guess if you had a case where there was a password without a user then we have a problem. |
Good point, that works fine. |
I probably missed something, are we ok with |
This could also be handled by providing aliases: cli.StringFlag {
Name: "src-username, suser"
// …
}and then (or even OTOH it is more typing than |
|
runcom I am just giving a username not a password |
| SignBy: signBy, | ||
| ReportWriter: os.Stdout, | ||
| SourceCtx: sourceCtx, | ||
| DestinationCtx: destinationCtx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is unavoidable :/
|
Overall, I like the separation of username/password but it does mean quite a bit of extra typing. WRT the too-long-option names, we can provide shortcuts but it would still be nice to at least allow using long readable ones ( = overall I don’t have a strong opinion on the single/two-argument decision. |
Sadly, we can’t, when uploading to Ouch. (This does not immediately affect this PR because that is only setting a docker/distribution username:password. But any more such cases, and telling the user to run |
f46a027 to
3f88a84
Compare
cmd/skopeo/utils.go
Outdated
| if err != nil { | ||
| return nil, err | ||
| } | ||
| fmt.Println(username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like debug outpuy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup I'll drop this
|
Missing changes to man pages and bash completions. |
|
Yup, if @mtrmac ack on the changes done so far, I'll update man, docs and everything else (adding tests also) |
aa1dc73 to
5d246b3
Compare
README.md
Outdated
| Private registries with authentication | ||
| - | ||
| When interacting with private registries, `skopeo` first looks for the Docker's cli config file (usually located at `$HOME/.docker/config.json`) to get the credentials needed to authenticate. When the file isn't available it falls back looking for `--username` and `--password` flags. The ultimate fallback, as Docker does, is to provide an empty authentication when interacting with those registries. | ||
| When interacting with private registries, `skopeo` first looks for the Docker's cli config file (usually located at `$HOME/.docker/config.json`) to get the credentials needed to authenticate. When the file isn't available it falls back looking for `--creds` (for `skopeo inspect`) or `--src-creds|--dest-creds` (for `skopeo copy`) flags. The ultimate fallback, as Docker does, is to provide an empty authentication when interacting with those registries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is wrong. If the user specified --creds, --src-creds, --dest-creds, it should override content in config.json rather then fall back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is wrong. If the user specified --creds, --src-creds, --dest-creds, it should override content in config.json rather then fall back.
Yeah, it's already this way, this piece of the README is wrong, I'll fix it.
docs/skopeo.1.md
Outdated
|
|
||
| **--sign-by=**_key-id_ add a signature using that key ID for an image name corresponding to _destination-image_ | ||
|
|
||
| **--src-creds** _username:password_ for accessing the source registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
_username[:password]_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very likely, I'll fix it
|
Still missing bash completion fixes. |
where is bash completion? |
|
Looks like it only generates one level of bash completions. Lets ignore this for now and we can open an issue to have a much more complete bach completions. |
ack, there's already an issue upstream which tracks this urfave/cli#188 |
README.md
Outdated
| # passing --username and --password - we can see that everything goes fine | ||
| $ skopeo --docker-cfg="" --username=testuser --password=testpassword inspect docker://myregistrydomain.com:5000/busybox | ||
| # passing --creds - we can see that everything goes fine | ||
| $ skopeo --docker-cfg="" --creds=testuser:testpassword inspect docker://myregistrydomain.com:5000/busybox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--docker-cfg seems not to exist at all
cmd/skopeo/delete.go
Outdated
| if err := ref.DeleteImage(contextFromGlobalOptions(context)); err != nil { | ||
| ctx := contextFromGlobalOptions(context) | ||
| if context.IsSet("creds") { | ||
| ctx.DockerAuthConfig, err = getDockerAuth(context.String("creds")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If everyone is going to use it like this, shouldn't it be folded into contextFromGlobalOptions(context, creds-option-name)?
cmd/skopeo/copy.go
Outdated
| cli.StringFlag{ | ||
| Name: "src-creds, screds", | ||
| Value: "", | ||
| Usage: "Use `USERNAME:PASSWORD` for accessing the source registry", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this use USERNAME[:PASSWORD], i.e. does that work with the template-variable markers? (If so, please fix everywhere)
| // ParseImage converts image URL-like string to an initialized handler for that image. | ||
| // parseImage converts image URL-like string to an initialized handler for that image. | ||
| // The caller must call .Close() on the returned Image. | ||
| func parseImage(c *cli.Context) (types.Image, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should parseImageSource be also updated to support --creds? (This would make it work for skopeo layers, though I am more concerned about the API symmetry than layers as such)
5d246b3 to
c8fd763
Compare
mtrmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
cmd/skopeo/utils.go
Outdated
| func contextFromGlobalOptions(c *cli.Context) *types.SystemContext { | ||
| tlsVerify := c.GlobalBoolT("tls-verify") | ||
| func contextFromGlobalOptions(c *cli.Context, credsFlag string) (*types.SystemContext, error) { | ||
| ctx := newBaseSystemContext(c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think we need the separate newBaseSystemContext function now that credsFlag is handled inline. (Eventually we may support credsFlag == "" to turn that off, but we don’t need that now.)
This does work just fine, feel free to merge as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
|
Bash Completions #256 |
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
c8fd763 to
342ba18
Compare
|
my bad, I have to fix containers/image and revendor here. I'll do it asap, sorry |
We already use global flags for docker specific stuff. This patch enables
--usernameand--passwordto be passed down tocontainers/imageto setup docker's registries auth.Fixes #253
@mtrmac @cyphar PTAL
Signed-off-by: Antonio Murdaca runcom@redhat.com