Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultPrivateKeyBits = 1024
Default bit size of a generated private key.
Variables ¶
This section is empty.
Functions ¶
func DefaultHasJoinedURL ¶ added in v0.12.0
DefaultHasJoinedURL is the default implementation of a HasJoinedURLFn.
Types ¶
type Authenticator ¶
type Authenticator interface { // Returns the public key encoded in ASN.1 DER form. PublicKey() []byte // 1) Verifies the verify token sent by joining client. Verify(encryptedVerifyToken, actualVerifyToken []byte) (equal bool, err error) DecryptSharedSecret(encrypted []byte) (decrypted []byte, err error) // 3) Generate server id to be used with AuthenticateJoin. GenerateServerID(decryptedSharedSecret []byte) (serverID string, err error) // 4) Authenticates a joining user. The ip is optional. AuthenticateJoin(ctx context.Context, serverID, username, ip string) (Response, error) }
Authenticator can authenticate joining Minecraft clients.
func New ¶
func New(options Options) (Authenticator, error)
New returns a new basic Mojang user authenticator.
type HasJoinedURLFn ¶ added in v0.12.0
HasJoinedURLFn returns the url to authenticate a joining online mode user. Note that userIP may be empty. See DefaultHasJoinedURL for the default implementation.
type Options ¶
type Options struct { // This setting allows to an authentication url other // than the official "hasJoined" Mojang API endpoint. // The returned url is used to authenticate a joining // online mode user. // If not set, DefaultHasJoinedURL is used. HasJoinedURLFn HasJoinedURLFn // The servers private key. // If none is set, a new one will be generated. PrivateKey *rsa.PrivateKey // PrivateKey is not set, // the bit size of a generated private key. // The default is DefaultPrivateKeyBits. PrivateKeyBits int // The http client to query the Mojang API. // If none is set, a new one is created. Client *http.Client }
Options to create a new Authenticator.
Click to show internal directories.
Click to hide internal directories.