()
| 154 | } |
| 155 | |
| 156 | func generateNonce() string { |
| 157 | b := make([]byte, 16) |
| 158 | if _, err := rand.Read(b); err != nil { |
| 159 | // OAuth state nonce — an all-zero nonce defeats the CSRF |
| 160 | // protection it exists to provide. Panic rather than silently |
| 161 | // emit a predictable value. |
| 162 | panic(fmt.Sprintf("auth: crypto/rand failed: %v", err)) |
| 163 | } |
| 164 | return hex.EncodeToString(b) |
| 165 | } |
| 166 | |
| 167 | func validateCLICallbackURL(raw string) (*url.URL, error) { |
| 168 | if raw == "" { |