auth

package
v0.0.0-...-85e05f8 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DoLoginURI URL used for login
	DoLoginURI string = "/login/dologin"
	// IsLoggedInURI URL used to check if user is logged in
	IsLoggedInURI string = "/actions/GetNotificationCounts"
)
View Source
const GetRSAKeyURI = "/login/getrsakey"

GetRSAKeyURI is the URI used to get the RSA Key in prod

Variables

View Source
var ErrCaptchaNeededNeeded = errors.New("Captcha needed")

ErrCaptchaNeededNeeded is returned when the login requires a captcha

View Source
var ErrEmailAuthNeeded = errors.New("Email auth needed")

ErrEmailAuthNeeded is returned when the login requires an email code

View Source
var ErrTwoFactorNeeded = errors.New("Two factor auth needed")

ErrTwoFactorNeeded is returned when the user needs to give a two factor code

Functions

func AlignTime

func AlignTime() error

AlignTime Aligns system time with the Steam server time. Not super advanced; probably not taking some things into account that it should. Necessary to generate up-to-date codes. In general, this will have an error of less than a second, assuming Steam is operational.

func EncryptPassword

func EncryptPassword(password string, rsaKey *RSAKey) (string, error)

EncryptPassword will RSA encode the password with the key provided

func GetSteamTime

func GetSteamTime() int64

GetSteamTime return the time adjusted with the steam diff

func IsLoggedIn

func IsLoggedIn(client *http.Client) (bool, error)

IsLoggedIn checks if a user is logged in or not

Types

type OAuth

type OAuth struct {
	SteamID       mangosteam.SteamID `db:"osteam_id" json:"steamid,string"`
	OAuthToken    string             `json:"auth"`
	Token         string             `json:"token"`
	TokenSecure   string             `json:"token_secure"`
	LastSessionID string             `json:"webcookie"`
}

OAuth is what will be used in future requests to specify we are logged in

func DoLogin

func DoLogin(
	client *http.Client,
	username string,
	encryptedPassword string,
	rsatimestamp string,
	emailauthKeyedIn string,
	captchaGID string,
	captchaKeyedIn string,
	twoFactorCode string,
) (OAuth, error)

DoLogin is used to log in the steam account after we got the encrypted password

type RSAKey

type RSAKey struct {
	PublicKeyModulus  string `json:"publickey_mod"`
	PublicKeyExponent string `json:"publickey_exp"`
	Timestamp         string `json:"timestamp"`
}

RSAKey represent the key for encoding password

func GetRSAKey

func GetRSAKey(username string) (*RSAKey, error)

GetRSAKey queries steam to get the key needed to encode the password

type SteamGuardAccount

type SteamGuardAccount struct {
	SharedSecret   string `json:"shared_secret"`
	SerialNumber   string `json:"serial_number"`
	RevocationCode string `json:"revocation_code"`
	URI            string `json:"uri"`
	ServerTime     int64  `json:"server_time,string"`
	AccountName    string `json:"account_name"`
	TokenGID       string `json:"token_gid"`
	IdentitySecret string `json:"identity_secret"`
	Secret1        string `json:"secret_1"`
	Status         int32  `json:"status"`
	DeviceID       string `json:"device_id"`
	// Set to true if the authenticator has actually been applied to the account.
	FullyEnrolled bool `json:"fully_enrolled"`
}

SteamGuardAccount represents the data needed to generate a code

func (*SteamGuardAccount) GenerateSteamGuardCode

func (a *SteamGuardAccount) GenerateSteamGuardCode() (string, error)

GenerateSteamGuardCode gives a steamgaurd code for login

func (*SteamGuardAccount) GenerateSteamGuardCodeForTime

func (a *SteamGuardAccount) GenerateSteamGuardCodeForTime(t int64) (string, error)

GenerateSteamGuardCodeForTime according to the server time

Jump to

Keyboard shortcuts

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