Documentation
¶
Overview ¶
Package cfaccess checks Cloudflare Access tokens: the JWT that Cloudflare Access puts in the Cf-Access-Jwt-Assertion header (and the CF_Authorization cookie) of every request it lets through to an application behind a Cloudflare Tunnel.
A token is accepted only if it is signed with RS256 by one of the team's current signing keys, published at https://TEAM/cdn-cgi/access/certs; if its audience is the application's AUD tag and its issuer is https://TEAM; if it carries exp, iat, aud and iss; if it has not expired and is already valid (exp and nbf, with a little clock skew); and, when an email allowlist is configured, if its email is on the list.
The keys are cached for about an hour. A token whose key ID the cache does not know makes the verifier fetch the keys again (Cloudflare rotates them), at most once every refetchEvery, so forged key IDs cannot turn the verifier into a request amplifier.
Index ¶
Constants ¶
const ( Header = "Cf-Access-Jwt-Assertion" Cookie = "CF_Authorization" )
Header and Cookie carry the token.
Variables ¶
var ErrNoToken = errors.New("no Cloudflare Access token")
ErrNoToken: the request carries no token.
Functions ¶
func FromCloudflare ¶
FromCloudflare reports whether a request came through Cloudflare: it carries a header that Cloudflare sets.
Types ¶
type Config ¶
type Config struct {
// Team is the team domain (myteam.cloudflareaccess.com). A leading
// https:// and a trailing slash are ignored.
Team string
// AUD is the application's Audience (AUD) tag.
AUD string
// Emails, if not empty, are the only emails allowed in (compared
// lower-cased).
Emails []string
// CertsURL replaces https://TEAM/cdn-cgi/access/certs (tests).
CertsURL string
// Client fetches the keys; default a client with a 10 s timeout.
Client *http.Client
// Now replaces the clock (tests).
Now func() time.Time
}
Config configures a Verifier.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cfaccesstest makes Cloudflare Access tokens for tests: an RSA signing key set, its JWKS document and signed JWTs.
|
Package cfaccesstest makes Cloudflare Access tokens for tests: an RSA signing key set, its JWKS document and signed JWTs. |