parseAudience creates the ca audience url from the ca-url
(ctx *cli.Context, tokType int)
| 37 | |
| 38 | // parseAudience creates the ca audience url from the ca-url |
| 39 | func parseAudience(ctx *cli.Context, tokType int) (string, error) { |
| 40 | caURL, err := flags.ParseCaURL(ctx) |
| 41 | if err != nil { |
| 42 | return "", err |
| 43 | } |
| 44 | |
| 45 | audience, err := url.Parse(caURL) |
| 46 | if err != nil { |
| 47 | return "", errs.InvalidFlagValue(ctx, "ca-url", caURL, "") |
| 48 | } |
| 49 | switch strings.ToLower(audience.Scheme) { |
| 50 | case "https", "": |
| 51 | var path string |
| 52 | switch tokType { |
| 53 | case SignType: |
| 54 | path = "/1.0/sign" |
| 55 | case RenewType: |
| 56 | path = "/1.0/renew" |
| 57 | case RevokeType: |
| 58 | path = "/1.0/revoke" |
| 59 | case SSHUserSignType, SSHHostSignType: |
| 60 | path = "/1.0/ssh/sign" |
| 61 | case SSHRevokeType: |
| 62 | path = "/1.0/ssh/revoke" |
| 63 | case SSHRenewType: |
| 64 | path = "/1.0/ssh/renew" |
| 65 | case SSHRekeyType: |
| 66 | path = "/1.0/ssh/rekey" |
| 67 | default: |
| 68 | return "", errors.Errorf("unexpected token type: %d", tokType) |
| 69 | } |
| 70 | audience.Scheme = "https" |
| 71 | audience = audience.ResolveReference(&url.URL{Path: path}) |
| 72 | return audience.String(), nil |
| 73 | default: |
| 74 | return "", errs.InvalidFlagValue(ctx, "ca-url", caURL, "") |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // ACMETokenError is the error type returned when the user attempts a Token Flow |
| 79 | // while using an ACME provisioner. |
no test coverage detected
searching dependent graphs…