auth

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default bit size of a generated private key.
	DefaultPrivateKeyBits = 1024
)

Variables

This section is empty.

Functions

This section is empty.

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)
	// 2) Decrypt shared secret sent by client.
	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)
	// Returns a new Authenticator that uses the specified logger.
	WithLogger(logger logr.Logger) Authenticator
}

Authenticator can authenticate joining Minecraft clients.

func New

func New(options Options) (Authenticator, error)

New returns a new basic Mojang user authenticator.

type Options

type Options struct {
	// 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.

type Response

type Response interface {
	OnlineMode() bool // Whether the user is in online mode
	// Extracts the GameProfile from an authenticated client.
	// Returns nil if OnlineMode is false.
	GameProfile() (*profile.GameProfile, error)
}

Response is the authentication response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL