You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
683 B
33 lines
683 B
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package cli
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/peterbourgon/ff/v3/ffcli"
|
|
)
|
|
|
|
var idTokenCmd = &ffcli.Command{
|
|
Name: "id-token",
|
|
ShortUsage: "id-token <aud>",
|
|
ShortHelp: "fetch an OIDC id-token for the Tailscale machine",
|
|
Exec: runIDToken,
|
|
}
|
|
|
|
func runIDToken(ctx context.Context, args []string) error {
|
|
if len(args) != 1 {
|
|
return errors.New("usage: id-token <aud>")
|
|
}
|
|
|
|
tr, err := localClient.IDToken(ctx, args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
outln(tr.IDToken)
|
|
return nil
|
|
}
|
|
|