Documentation
¶
Overview ¶
Package auth is the two credentials a harness checks. An api key lets a connector call every HTTP route. A join secret lets a machine join the mesh as a worker; it can add a worker and nothing else. Both kinds live hashed in one table on the admin drive. What a person pastes is a token: the kind, the key of the harness its holder finds through the pointer, and the secret itself.
mp_<kind>_<harness key>.<secret>
Index ¶
- Constants
- func Addr(r *http.Request) string
- func Hash(secret string) string
- func Parse(kind, token string) (key, secret string, err error)
- func Token(kind, key, secret string) string
- type Entry
- type Limit
- type Store
- func (s Store) Bearer(l *Limit, next http.Handler) http.Handler
- func (s Store) Check(kind, secret string) bool
- func (s Store) Find(kind, secret string) (Entry, bool)
- func (s Store) Issue(kind, name string, ephemeral bool) (string, error)
- func (s Store) Load() (Table, error)
- func (s Store) Revoke(kind, name string) error
- func (s Store) Set(kind, name, secret string) error
- type Table
Constants ¶
const ( Key = "key" // a connector's credential: every HTTP route Join = "join" // a worker's credential: joining the mesh )
Variables ¶
This section is empty.
Functions ¶
func Addr ¶ added in v0.2.0
Addr is who sent r: the client address cloudflared puts in CF-Connecting-IP, else the peer. The harness listens on loopback only, so every peer is cloudflared or this machine, and the header can be trusted.
Types ¶
type Limit ¶ added in v0.2.0
type Limit struct {
// contains filtered or unexported fields
}
Limit counts refused credentials of both kinds by address, and turns an address away for the rest of a window once it has too many. The window is one for every address, so an address may come back early. It keeps down noise and log spam; a 26-character secret needs no limit against guessing.
type Store ¶
type Store struct{ Path string }
Store is the table as a file, read on every check so a new or revoked entry counts at once.
func (Store) Bearer ¶
Bearer refuses a request whose Authorization: Bearer is not a live api key, and one from an address l turns away. A request with no key is refused but not counted: it guesses nothing.