-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Download mTLS files from Web #14526
Download mTLS files from Web #14526
Conversation
a97baa9
to
1fecfe0
Compare
1fecfe0
to
031f53e
Compare
c9c6c2d
to
1879089
Compare
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.
@marcoandredinis Didn't review in detail yet but a couple of things I've noticed so far:
- Agree with changing method to POST (or PUT) and building archive in memory.
- We should use
.tar.gz
or just.tar
archive instead of.zip
.
8a07af7
to
9c4425c
Compare
@hugoShaka @r0mant |
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.
LGTM, one minor comment
445c004
to
09441d0
Compare
09441d0
to
e938bab
Compare
@r0mant friendly ping |
28741c8
to
3711f5f
Compare
9edeebd
to
666dd58
Compare
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.
Couple final remarks, but otherwise it looks good now!
req.Principals = append([]string{"node"}, req.Principals...) | ||
} | ||
|
||
subject := pkix.Name{CommonName: req.Principals[0]} |
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 noticed that we don't validate that req.Principals
is not empty anywhere here, might be worth adding a check somewhere here to avoid panics.
lib/services/provisioning.go
Outdated
@@ -38,6 +38,7 @@ type Provisioner interface { | |||
GetToken(ctx context.Context, token string) (types.ProvisionToken, error) | |||
|
|||
// DeleteToken deletes provisioning token | |||
// Imlementations must guarantee that this returns trace.NotFound error is the token doesn't exist |
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.
// Imlementations must guarantee that this returns trace.NotFound error is the token doesn't exist | |
// Imlementations must guarantee that this returns trace.NotFound error if the token doesn't exist |
lib/web/apiserver.go
Outdated
@@ -2693,6 +2696,61 @@ func (h *Handler) WithClusterAuth(fn ClusterHandler) httprouter.Handle { | |||
}) | |||
} | |||
|
|||
// ProvisionTokenHandler is a authenticated handler that is called for some existing Token | |||
type ProvisionTokenHandler func(w http.ResponseWriter, r *http.Request, p httprouter.Params, site reversetunnel.RemoteSite, roles types.SystemRoles) (interface{}, 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.
Why not just pass the entire token to the handler instead of roles? Would make things a little cleaner I think.
tool/tctl/common/auth_command.go
Outdated
if outputFormat == identityfile.FormatSnowflake { | ||
delete(tplVars, "output") | ||
} |
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.
Do we need this? If the template variable is present but just not used in the template, it should be fine, right?
ef66db6
to
472114a
Compare
New endpoint to return an archive with mTLS files for a given resource. This endpoint is protect by a Provision Token which is consumed by the API Call: it is used as a one time password.
It also changes the format from zip to tar.gz
472114a
to
25ecbc9
Compare
@marcoandredinis See the table below for backport results.
|
In the context of Teleport Discover we are trying to ease the usage of Teleport for the user's first interaction. When adding a new database resource the user must, among other things, generate the mTLS files Examples: https://goteleport.com/docs/database-access/guides/postgres-self-hosted/#step-25-create-a-certificatekey-pair https://goteleport.com/docs/database-access/guides/mysql-self-hosted/#step-24-create-a-certificatekey-pair This PR aims to reduce this friction: the user should be able to setup the resource without prior setup of local tools (`tsh login`) We're doing this by providing an endpoint that will return those exact files Demo ```shell marco@lenix ~/p/downloadmtls> curl --silent --insecure 'https://127.0.0.1.nip.io:3080/v1/webapi/sites/lenix/sign' --dat a '{"hostname":"discover.example.com", "ttl":"9999h", "format": "db"}' --header 'Authorization: Bearer 308bf3dd3019ddc4 2cff44a48e028480' --header 'Content-Type: application/json' -OJ marco@lenix ~/p/downloadmtls> tar -xvf teleport_mTLS_discover.example.com.tar.gz server.key server.crt server.cas marco@lenix ~/p/downloadmtls> head -1 server.* ==> server.cas <== -----BEGIN CERTIFICATE----- ==> server.crt <== -----BEGIN CERTIFICATE----- ==> server.key <== -----BEGIN RSA PRIVATE KEY----- ``` Fixes #14049
FYI @LKozlowski - this may help you automate the setup for Desktop Access |
Download mTLS files from Web (#14526) In the context of Teleport Discover we are trying to ease the usage of Teleport for the user's first interaction. When adding a new database resource the user must, among other things, generate the mTLS files Examples: https://goteleport.com/docs/database-access/guides/postgres-self-hosted/#step-25-create-a-certificatekey-pair https://goteleport.com/docs/database-access/guides/mysql-self-hosted/#step-24-create-a-certificatekey-pair This PR aims to reduce this friction: the user should be able to setup the resource without prior setup of local tools (`tsh login`) We're doing this by providing an endpoint that will return those exact files Demo ```shell marco@lenix ~/p/downloadmtls> curl --silent --insecure 'https://127.0.0.1.nip.io:3080/v1/webapi/sites/lenix/sign' --dat a '{"hostname":"discover.example.com", "ttl":"9999h", "format": "db"}' --header 'Authorization: Bearer 308bf3dd3019ddc4 2cff44a48e028480' --header 'Content-Type: application/json' -OJ marco@lenix ~/p/downloadmtls> tar -xvf teleport_mTLS_discover.example.com.tar.gz server.key server.crt server.cas marco@lenix ~/p/downloadmtls> head -1 server.* ==> server.cas <== -----BEGIN CERTIFICATE----- ==> server.crt <== -----BEGIN CERTIFICATE----- ==> server.key <== -----BEGIN RSA PRIVATE KEY----- ``` Fixes #14049
Oh, nice, Looks promising. Thanks! |
In the context of Teleport Discover we are trying to ease the usage of Teleport for the user's first interaction.
When adding a new database resource the user must, among other things, generate the mTLS files
Examples:
https://goteleport.com/docs/database-access/guides/postgres-self-hosted/#step-25-create-a-certificatekey-pair
https://goteleport.com/docs/database-access/guides/mysql-self-hosted/#step-24-create-a-certificatekey-pair
This PR aims to reduce this friction: the user should be able to setup the resource without prior setup of local tools (
tsh login
)We're doing this by providing an endpoint that will return those exact files
Demo
Fixes #14049