Documentation ¶
Index ¶
Constants ¶
const ( AuthHeaderDevice = "Device-17" AuthHeaderToken = "Token-17" AuthHeaderNextToken = "Next-Token-17" AuthHeaderNextTokenDeprecated = "Next_token_17" )
Authentication Headers.
const ( CAAuthenticateURL = "/authenticate" CAProfileURL = "/user/profile" CAGetTokensURL = "/tokens" )
Customer Agent URLs.
const ( CHAuthenticateURL = "/v1/authenticate" CHUserProfileURL = "/v1/user_profile" )
Customer Hub URLs.
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. SubscriptionStateManual = "manual" // Manual renewal. SubscriptionStateActive = "active" // Automatic renewal. SubscriptionStateCancelled = "cancelled" // Automatic, but canceled. ChargeStatePending = "pending" ChargeStateCompleted = "completed" ChargeStateDead = "dead" )
User, Subscription and Charge states.
const ( // StatusInvalidAuth [401 Unauthorized] is returned when the credentials are // invalid or the user was logged out. StatusInvalidAuth = 401 // StatusNoAccess [403 Forbidden] is returned when the user does not have // an active subscription or the subscription does not include the required // feature for the request. StatusNoAccess = 403 // StatusInvalidDevice [410 Gone] is returned when the device trying to // log into does not exist. StatusInvalidDevice = 410 // 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 // StatusUnknownError is a special status code that signifies an unknown or // unexpected error by the API. StatusUnknownError = -1 // StatusConnectionError is a special status code that signifies a // connection error. StatusConnectionError = -2 )
Agent and Hub return statuses.
const ( FeatureSPN = FeatureID("spn") FeatureSafingSupport = FeatureID("support") FeatureHistory = FeatureID("history") FeatureBWVis = FeatureID("bw-vis") FeatureVPNCompat = FeatureID("vpn-compat") )
A list of all supported features.
Variables ¶
var ( ErrMissingDeviceID = errors.New("missing device ID") ErrMissingToken = errors.New("missing token") )
Errors.
Functions ¶
func ApplyNextTokenToResponse ¶
func ApplyNextTokenToResponse(w http.ResponseWriter, token string)
ApplyNextTokenToResponse applies the next authentication token to a response.
Types ¶
type AuthToken ¶
AuthToken holds an authentication token.
func GetAuthTokenFromRequest ¶
GetAuthTokenFromRequest extracts an authentication token from a request.
type FeatureID ¶
type FeatureID string
FeatureID defines a feature that requires a plan/subscription.
type Plan ¶
type Plan struct { Name string `json:"name"` Amount int `json:"amount"` Months int `json:"months"` Renewable bool `json:"renewable"` FeatureIDs []FeatureID `json:"feature_ids"` }
Plan describes an SPN subscription plan.
type Subscription ¶
type Subscription struct { EndsAt *time.Time `json:"ends_at"` State string `json:"state"` NextBillingDate *time.Time `json:"next_billing_date"` PaymentProvider string `json:"payment_provider"` }
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"` View *View `json:"view"` }
User describes an SPN user account.
func (*User) MayUse ¶
MayUse returns whether the user may currently use the feature identified by the given feature ID. Leave feature ID empty to check without feature.
func (*User) MayUsePrioritySupport ¶
MayUsePrioritySupport returns whether the user may currently use the priority support.
func (*User) UpdateView ¶
UpdateView updates the view and handles plan/package fallbacks.