steamauth

package
v0.0.0-...-72424b2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package steamauth wraps Steam's user authentication API.

This package is available on both clients and servers.

See the Steam User Authentication documentation for more details. <https://partner.steamgames.com/doc/features/auth>

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTicket    = errors.New("steamworks/steamauth: invalid ticket")
	ErrDuplicateRequest = errors.New("steamworks/steamauth: there is already an active session for this SteamID")
	ErrInvalidVersion   = errors.New("steamworks/steamauth: ticket is from an incompatible version of the Steam API")
	ErrGameMismatch     = errors.New("steamworks/steamauth: ticket is for a different game")
	ErrExpired          = errors.New("steamworks/steamauth: ticket is expired")
	ErrUnknown          = errors.New("steamworks/steamauth: unknown error")
)

Errors that can be returned from BeginSession.

View Source
var ErrSessionAlreadyClosed = errors.New("steamworks/steamauth: session was already closed")

ErrSessionAlreadyClosed is returned by Session.Close if the session is closed multiple times.

Functions

func CreateTicket

func CreateTicket() (ticket []byte, cancel func())

CreateTicket generates a sequence of bytes that verifies your identity and ownership of a game to another Steam user or server.

The ticket can only be used once, and cancel should be called when the ticket is no longer in use - that is, when the session ends.

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session represents a Steam authentication session. All methods on Session are safe to call concurrently.

Sessions must be closed when they are no longer in use. Failing to do so will result in a message being written to the standard error stream.

func BeginSession

func BeginSession(ticket []byte, claimedID steamworks.SteamID) (*Session, error)

BeginSession verifies a ticket returned by CreateTicket from another Steam user. The returned session must be closed when it is no longer in use.

Sessions start with StatusUnknown. In this state, the session should continue but the user's claimed identity should not be trusted. If a session transitions to the StatusOK state, the claimed identity can be trusted. If the state is any other value, the session is invalid.

When a session is closed, it may transition to the StatusCanceled state before transitioning to the StatusClosed state if the remote user closes the session first. If the user is already disconnecting, this can be ignored as both sides of the connection have already agreed that the session is to be closed.

If the error returned by this function is ErrDuplicateRequest, the session may or may not be nil. If the error is nil, the session will not be nil. In any other case, the session is nil.

func (*Session) Change

func (s *Session) Change() <-chan SessionStatus

Change returns a channel which receives status changes. The channel is closed by Close, so closing a session will cause this channel to repeatedly receive StatusClosed.

func (*Session) ClaimedID

func (s *Session) ClaimedID() steamworks.SteamID

ClaimedID returns the SteamID of the remote user for this session.

This value should only be trusted if Status is StatusOK.

func (*Session) Close

func (s *Session) Close() error

Close closes a Session. If the session has already been closed, ErrSessionAlreadyClosed is returned and no other action is taken.

Close must be called when the session ends.

func (*Session) OwnerID

func (s *Session) OwnerID() steamworks.SteamID

OwnerID returns the SteamID of the user who owns this game.

This may be different than ClaimedID if the game is shared. This function's return value may be zero or invalid if Status was never StatusOK.

func (*Session) OwnsDLC

func (s *Session) OwnsDLC(dlc steamworks.AppID) bool

OwnsDLC returns true if the user owns the specified DLC, or false if the user does not own the DLC or if the session is not authenticated.

func (*Session) Status

func (s *Session) Status() SessionStatus

Status returns the current status of this session.

See the documentation for SessionStatus for information on what the various possible values mean.

type SessionStatus

type SessionStatus internal.EAuthSessionResponse

SessionStatus represents the current status of an authentication session.

StatusUnknown means that Steam has not yet responded to the verification request. The session should continue, but the user's claimed identity should not be trusted.

StatusOK means that Steam has verified that the user is who they say they are and that they own the game.

All other statuses are errors and should result in the session being terminated in most use cases. Valve recommends that in this case, in P2P sessions, the user that failed to authenticate should be kicked, and if the other users in the lobby do not also kick that user, the lobby should be left.

const (
	// StatusClosed means that the session has been closed. This status can
	// only be received from the Change channel as a result of the channel being
	// closed, which means the channel will always be "ready" once this is the
	// session's status.
	StatusClosed SessionStatus = SessionStatus(0)
	// StatusUnknown means that Steam has not yet responded to the verification
	// request. The session should continue, but the user's claimed identity
	// should not be trusted.
	StatusUnknown SessionStatus = SessionStatus(1)
	// StatusOK means Steam has verified the user is online, the ticket is
	// valid, and the ticket has not been reused.
	StatusOK SessionStatus = SessionStatus(internal.EAuthSessionResponse_OK + 2)
	// StatusUserNotConnectedToSteam means the user in question is not
	// connected to steam.
	StatusUserNotConnectedToSteam SessionStatus = SessionStatus(internal.EAuthSessionResponse_UserNotConnectedToSteam + 2)
	// StatusNoLicenseOrExpired means the user doesn't have a license for this
	// App ID or the ticket has expired.
	StatusNoLicenseOrExpired SessionStatus = SessionStatus(internal.EAuthSessionResponse_NoLicenseOrExpired + 2)
	// StatusVACBanned means the user is VAC banned for this game.
	StatusVACBanned SessionStatus = SessionStatus(internal.EAuthSessionResponse_VACBanned + 2)
	// StatusLoggedInElsewhere means the user account has logged in elsewhere
	// and the session containing the game instance has been disconnected.
	StatusLoggedInElsewhere SessionStatus = SessionStatus(internal.EAuthSessionResponse_LoggedInElseWhere + 2)
	// StatusVACCheckTimedOut means VAC has been unable to perform anti-cheat
	// checks on this user.
	StatusVACCheckTimedOut SessionStatus = SessionStatus(internal.EAuthSessionResponse_VACCheckTimedOut + 2)
	// StatusCanceled means the ticket has been canceled by the issuer.
	StatusCanceled SessionStatus = SessionStatus(internal.EAuthSessionResponse_AuthTicketCanceled + 2)
	// StatusInvalidAlreadyUsed means this ticket has already been used. It is
	// not valid.
	StatusInvalidAlreadyUsed SessionStatus = SessionStatus(internal.EAuthSessionResponse_AuthTicketInvalidAlreadyUsed + 2)
	// StatusInvalid means this ticket is not from a user instance currently
	// connected to steam.
	StatusInvalid SessionStatus = SessionStatus(internal.EAuthSessionResponse_AuthTicketInvalid + 2)
	// StatusPublisherIssuedBan means the user is banned for this game. The ban
	// came via the web api and not VAC.
	StatusPublisherIssuedBan SessionStatus = SessionStatus(internal.EAuthSessionResponse_PublisherIssuedBan + 2)
)

func (SessionStatus) String

func (i SessionStatus) String() string

Jump to

Keyboard shortcuts

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