account

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: AGPL-3.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AuthHeaderDevice              = "Device-17"
	AuthHeaderToken               = "Token-17"
	AuthHeaderNextToken           = "Next-Token-17"
	AuthHeaderNextTokenDeprecated = "Next_token_17"
)
View Source
const (
	CAAuthenticateURL = "/authenticate"
	CAProfileURL      = "/user/profile"
	CAGetTokensURL    = "/tokens"
)
View Source
const (
	CHAuthenticateURL = "/v1/authenticate"
	CHUserProfileURL  = "/v1/user_profile"
)
View Source
const (
	// UserStateNone is only used within Portmaster for saving information for
	// logging into the same device.
	UserStateNone      = ""
	UserStateFresh     = "fresh"
	UserStateQueued    = "queued"
	UserStateApproved  = "approved"
	UserStateSuspended = "suspended"
	UserStateLoggedOut = "loggedout" // Portmaster only.

	SubscriptionStatePending   = "pending"
	SubscriptionStateActive    = "active"
	SubscriptionStateCancelled = "cancelled"
	SubscriptionStateExpired   = "expired"

	ChargeStatePending   = "pending"
	ChargeStateCompleted = "completed"
	ChargeStateDead      = "dead"
)

User, Subscription and Charge states.

View Source
const (
	// StatusInvalidAuth [401 Unauthorized] is returned when the credentials are
	// invalid or the user was logged out.
	StatusInvalidAuth = 401
	// StatusInvalidDevice [404 Not Found] is returned when the device trying to
	// log into does not exist.
	StatusInvalidDevice = 404
	// StatusReachedDeviceLimit [409 Conflict] is returned when the device limit is reached.
	StatusReachedDeviceLimit = 409
	// StatusDeviceInactive [423 Locked] is returned when the device is locked.
	StatusDeviceInactive = 423
	// StatusNotLoggedIn [412 Precondition] is returned by the Portmaster, if an action required to be logged in, but the user is not logged in.
	StatusNotLoggedIn = 412
)

Agent and Hub return statuses.

Variables

View Source
var (
	ErrMissingDeviceID = errors.New("missing device ID")
	ErrMissingToken    = errors.New("missing token")
)

Functions

func ApplyNextTokenToResponse

func ApplyNextTokenToResponse(w http.ResponseWriter, token string)

func GetNextTokenFromResponse

func GetNextTokenFromResponse(resp *http.Response) (token string, ok bool)

Types

type AuthToken

type AuthToken struct {
	Device string
	Token  string
}

func GetAuthTokenFromRequest

func GetAuthTokenFromRequest(request *http.Request) (*AuthToken, error)

func (*AuthToken) ApplyTo

func (at *AuthToken) ApplyTo(request *http.Request)

type Device

type Device struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

Device describes a device of an SPN user.

type Plan

type Plan struct {
	Name      string `json:"name"`
	Amount    int    `json:"amount"`
	Months    int    `json:"months"`
	Renewable bool   `json:"renewable"`
}

Plan describes an SPN subscription plan.

type Subscription

type Subscription struct {
	EndsAt time.Time `json:"ends_at"`
	State  string    `json:"state"`
}

Subscription describes an SPN subscription.

type User

type User struct {
	Username     string        `json:"username"`
	State        string        `json:"state"`
	Balance      int           `json:"balance"`
	Device       *Device       `json:"device"`
	Subscription *Subscription `json:"subscription"`
	CurrentPlan  *Plan         `json:"current_plan"`
	NextPlan     *Plan         `json:"next_plan"`
}

User describes an SPN user account.

func (*User) MayUseSPN

func (u *User) MayUseSPN() bool

MayUseSPN return whether the user may currently use the SPN.

Jump to

Keyboard shortcuts

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