Documentation
¶
Overview ¶
Package auth logs players in to servers whose realm issues single-use tickets: jaenster's d2up realm stack and its login service, authd.
The player logs in once, through Discord in their browser. authd gives back a refresh token, which the launcher keeps. Before every box the launcher trades it for a fresh ticket (the account's password for one logon, valid a few minutes) and, with a relay, a tunnel token, and hands them to the game in its environment. A ticket is never cached or reused.
Index ¶
Constants ¶
const Handoff = "1"
Handoff is the D2UP_HANDOFF contract version the environment follows.
Variables ¶
var ErrLoggedOut = errors.New("logged out: log in again")
ErrLoggedOut is a refresh token authd no longer accepts: the player has to log in again.
var ErrTimedOut = errors.New("the login wasn't finished in time")
ErrTimedOut is a login the player didn't finish in the browser in time.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// Poll is the wait between /claim polls.
Poll time.Duration
// Timeout is how long a login may take in the browser.
Timeout time.Duration
// contains filtered or unexported fields
}
Client talks to one server's authd.
func New ¶
New returns a client for the profile's login service, fetching through f, which must allow the profile's hosts.
func (*Client) Claim ¶
Claim asks once whether the login behind nonce has finished. It answers nil, nil while the player is still in the browser.
type Grant ¶
type Grant struct {
Account string `json:"account"`
Ticket string `json:"ticket"`
// Refresh is only in the answer to a new login.
Refresh string `json:"refresh,omitempty"`
Name string `json:"name,omitempty"`
// Tunnel is the relay token, when the server runs one.
Tunnel string `json:"tunnel,omitempty"`
}
Grant is what authd answers to a login or a refresh.