| 93 | } |
| 94 | |
| 95 | func GenerateCodeChallenge(method, codeVerifier string) (string, error) { |
| 96 | switch method { |
| 97 | case CodeChallengeMethodPlain: |
| 98 | return codeVerifier, nil |
| 99 | case CodeChallengeMethodS256: |
| 100 | shaSum := sha256.Sum256([]byte(codeVerifier)) |
| 101 | return base64.RawURLEncoding.EncodeToString(shaSum[:]), nil |
| 102 | default: |
| 103 | return "", fmt.Errorf("unknown challenge method: %v", method) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | func cookieSignature(signer func() hash.Hash, args ...string) (string, error) { |
| 108 | h := hmac.New(signer, []byte(args[0])) |