Documentation
¶
Overview ¶
Package guard is what a service that other machines may reach shares with the others: the one bearer token it accepts (RFC 6750), where a token is read from, and the rule that a listener off loopback is served only with one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsB64Token ¶
IsB64Token reports whether s is a b64token of RFC 6750 § 2.1.
func IsLoopbackAddr ¶
IsLoopbackAddr reports whether a bound address can be reached from this machine only.
func IsLoopbackHost ¶
IsLoopbackHost reports whether a host name or address is this machine's loopback interface.
func ListenAddress ¶
ListenAddress reads a listening address as every service spells one: a port alone, or host:port whose host is empty, binds loopback (localhost).
Types ¶
type Refusal ¶
type Refusal int
Refusal is why an Authorization header was not accepted, or Accepted.
const ( // Accepted is a header carrying the token. Accepted Refusal = iota // NothingPresented is a request with no Authorization header. NothingPresented // NotBearer is an Authorization header of another scheme. NotBearer // Malformed is a Bearer header whose credentials are not a b64token. Malformed // Mismatch is a well-formed bearer token that is not this server's. Mismatch )
func (Refusal) ChallengeParams ¶
ChallengeParams are the error parameters of a WWW-Authenticate challenge, none when nothing was presented.
func (Refusal) Description ¶
Description says what was wrong, empty when nothing was presented.
func (Refusal) HTTPStatus ¶
HTTPStatus is the status a refusal is answered with: 400 for a header the server cannot read, 401 otherwise (RFC 6750 § 3.1).
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token is the one access token a service accepts (RFC 6750), issued out of band by whoever runs it; the zero value is no token.
func New ¶
New reads a token as RFC 6750 § 2.1 spells one (b64token), so a client can send what the server was given; anything else is refused.
func Read ¶
Read reads the token -token-file (one trailing line break dropped), -token or the environment variable env names, in that precedence; both flags set is refused, none and an empty variable is no token. The text is returned beside the token for a command that prints its configuration.