pkce

package
v1.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pkce checks a Proof Key for Code Exchange (RFC 7636), which ties a one-time code to the party that asked for it: the client sends a hash of a secret when it starts, and the secret itself when it redeems the code, so that a code intercepted on its way back -- by another app claiming the same URI scheme, say -- is worth nothing to whoever intercepted it.

Only S256. The "plain" method sends the secret where the hash should be, which defeats the point for exactly the interception it exists to stop.

Index

Constants

View Source
const MethodS256 = "S256"

MethodS256 is the one challenge method accepted.

Variables

This section is empty.

Functions

func ChallengeS256

func ChallengeS256(verifier string) string

ChallengeS256 is the S256 challenge for a verifier: base64url, without padding, of its SHA-256.

func MatchesS256

func MatchesS256(verifier string, challenge string) bool

MatchesS256 reports whether a verifier is the one a challenge was made from. A verifier of the wrong shape never matches, whatever it hashes to.

func ValidChallenge

func ValidChallenge(challenge string) bool

ValidChallenge reports whether a challenge has the shape an S256 one has, so that one which could never be matched is refused when the flow starts rather than when it is about to finish.

func ValidVerifier

func ValidVerifier(verifier string) bool

ValidVerifier reports whether a verifier is 43 to 128 characters of the unreserved set.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL