-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
auth: fetch tokens from client side #1660
Conversation
ts.mu.Lock() | ||
defer ts.mu.Unlock() | ||
|
||
fp := filepath.Join(ts.dir, ".token_seed") |
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.
Was hoping to avoid this but couldn't think of a better solution. Afaics if we don't do something like this we always have a possibility for a chosen-plaintext attack from the daemon side. Another possible way would be to use pbkdf/scrypt for the verification but didn't want to take the 100ms+ performance hit for this and waste cpu.
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.
Worth leaving a comment that describes this?
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
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.
fyi @justincormack
259df14
to
fa6ce06
Compare
"golang.org/x/sync/errgroup" | ||
) | ||
|
||
type MultiWriter struct { |
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.
These new progress handling functions are copied from buildx with slight modification. Buildx versions will be removed on next vendor.
fa6ce06
to
715fe26
Compare
return nil, err | ||
} | ||
|
||
if err := os.MkdirAll(filepath.Dir(fp), 0701); err != nil { |
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.
Just double checking, we want anyone to have access to paths inside the dir, but not be able to list the dir? Or is this supposed to be 0700
?
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.
On my machine it is 0755
actually, but cli does not seem to be consistent. The search bit should be set though as not all things in .docker
are secret. Eg. it may contain plugins that need to be executable.
FYI @thaJeztah
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.
In most cases, this would be inside the user's home-directory, which would likely not be accessible to the "world" already, correct? 😅
but cli does not seem to be consistent
Can you elaborate what's not consistent? Something that needs to be fixed?
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.
eg. https://github.com/docker/cli/blob/master/cli/context/store/metadatastore.go#L31
https://github.com/docker/cli/blob/master/cli/config/configfile/file.go#L187
There's at least one example for both cases
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.
updated to 0755
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.
Opened docker/cli#2727 for tracking on the CLI side.
Would 0755
be problematic if a custom config-directory is specified through --config
(potentially outside of ~/
?
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.
Not really problematic as the file itself is 0600
and this is just the parent directory. But if you want to be more safe I can put it back to 0700
. In 99% of the cases the directory already exists and all this will be ignored.
return nil, err | ||
} | ||
|
||
if err := ioutil.WriteFile(fp, dt, 0600); err != nil { |
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.
WriteFile
opens the file w/ O_TRUNC
, so if the daemon crashed at the exact wrong time, I think this file could end up existing but be empty, which would cause the json.Unmarshal
above to always return an error. Obviously pretty obscure, but if that happened the only recourse would be for the user to manually delete the file.
Maybe if the json unmarshal fails you can just assume the file is empty and start anew?
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.
Would you prefer a file lock?
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.
Sure lock would work, or you could write to a new temp file opened w/ O_EXCL
and rename(2)
it to the final one once done, whichever is easiest
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.
Added file lock
715fe26
to
08b152a
Compare
Signed-off-by: Tonis Tiigi <[email protected]>
08b152a
to
1f94445
Compare
This change broke configurations in Kubernetes like this one:
It's a common practise that credentials are mount to this directory with Kube secrets.
|
Hmm... I guess it's a bit of an odd situation where the temp-dir is read-only; is that common? (are temp-dirs always expected to be writable?) ^^ @tonistiigi looks because of https://github.com/moby/buildkit/pull/1660/files#r479909291 Are there paths that are required to be writable? |
Instead of sharing credentials with the daemon use session to request temporary tokens requested from the cli side. The tokens are still reused with resolvers like before and efficiency shouldn't suffer. @sipsma
Marking wip to add client-side progress injection making token requests visible. This turned out to be more complicated and I'm moving code from buildx to buildkit to achieve it.Signed-off-by: Tonis Tiigi [email protected]