generate state parameter value used to mitigate CSRF attacks more: https://auth0.com/docs/protocols/state-parameters
(size int)
| 299 | // generate state parameter value used to mitigate CSRF attacks |
| 300 | // more: https://auth0.com/docs/protocols/state-parameters |
| 301 | func generateState(size int) (string, error) { |
| 302 | b := make([]byte, size) |
| 303 | _, err := rand.Read(b) |
| 304 | if err != nil { |
| 305 | return "", err |
| 306 | } |
| 307 | |
| 308 | return base64.RawURLEncoding.EncodeToString(b), nil |
| 309 | } |
| 310 | |
| 311 | // check if slice contains a string. |
| 312 | func containsStr(s []string, u string) bool { |