MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / GenerateRandomState

Function GenerateRandomState

internal/misc/oauth.go:17–23  ·  view source on GitHub ↗

GenerateRandomState generates a cryptographically secure random state parameter for OAuth2 flows to prevent CSRF attacks. Returns: - string: A hexadecimal encoded random state string - error: An error if the random generation fails, nil otherwise

()

Source from the content-addressed store, hash-verified

15// - string: A hexadecimal encoded random state string
16// - error: An error if the random generation fails, nil otherwise
17func GenerateRandomState() (string, error) {
18 bytes := make([]byte, 16)
19 if _, err := rand.Read(bytes); err != nil {
20 return "", fmt.Errorf("failed to generate random bytes: %w", err)
21 }
22 return hex.EncodeToString(bytes), nil
23}
24
25// OAuthCallback captures the parsed OAuth callback parameters.
26type OAuthCallback struct {

Callers 8

RequestAnthropicTokenMethod · 0.92
RequestCodexTokenMethod · 0.92
RequestXAITokenMethod · 0.92
LoginMethod · 0.92
LoginMethod · 0.92
LoginMethod · 0.92
LoginMethod · 0.92

Calls 1

ReadMethod · 0.45

Tested by

no test coverage detected