(ctx *cli.Context)
| 112 | } |
| 113 | |
| 114 | func loginAction(ctx *cli.Context) error { |
| 115 | if err := errs.MinMaxNumberOfArguments(ctx, 0, 1); err != nil { |
| 116 | return err |
| 117 | } |
| 118 | |
| 119 | // Arguments |
| 120 | subject := ctx.Args().First() |
| 121 | if subject == "" { |
| 122 | subject = ctx.String("identity") |
| 123 | } |
| 124 | |
| 125 | principals := ctx.StringSlice("principal") |
| 126 | if subject != "" && len(principals) == 0 { |
| 127 | principals = []string{subject} |
| 128 | } |
| 129 | |
| 130 | comment := ctx.String("comment") |
| 131 | if comment == "" { |
| 132 | comment = subject |
| 133 | } |
| 134 | |
| 135 | // Flags |
| 136 | token := ctx.String("token") |
| 137 | isAddUser := ctx.Bool("add-user") |
| 138 | force := ctx.Bool("force") |
| 139 | insecure := ctx.Bool("insecure") |
| 140 | validAfter, validBefore, err := flags.ParseTimeDuration(ctx) |
| 141 | if err != nil { |
| 142 | return err |
| 143 | } |
| 144 | templateData, err := flags.ParseTemplateData(ctx) |
| 145 | if err != nil { |
| 146 | return err |
| 147 | } |
| 148 | |
| 149 | kty, curve, size, err := utils.GetKeyDetailsFromCLI(ctx, insecure, "kty", "curve", "size") |
| 150 | if err != nil { |
| 151 | return err |
| 152 | } |
| 153 | |
| 154 | // Connect to the SSH agent. |
| 155 | // step ssh login requires an ssh agent. |
| 156 | agent, err := sshutil.DialAgent() |
| 157 | if err != nil { |
| 158 | return err |
| 159 | } |
| 160 | |
| 161 | // Check for a previous key signed by the CA. |
| 162 | if !force { |
| 163 | client, err := cautils.NewClient(ctx) |
| 164 | if err != nil { |
| 165 | return err |
| 166 | } |
| 167 | opts := []sshutil.AgentOption{ |
| 168 | sshutil.WithRemoveExpiredCerts(time.Now()), |
| 169 | } |
| 170 | if roots, err := client.SSHRoots(); err == nil && len(roots.UserKeys) > 0 { |
| 171 | userKeys := make([]ssh.PublicKey, len(roots.UserKeys)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…