lib

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const GoogleOIDCConfigURL = "https://accounts.google.com/.well-known/openid-configuration"

Variables

View Source
var ValidUserViewershipModes = []ViewershipMode{
	{proto.ViewershipMode_Open, "open"},
	{proto.ViewershipMode_Closed, "closed"},
}

Functions

func AbortVanityBuild

func AbortVanityBuild(
	m shared.MetaContext,
	user *User,
	vhr *VHostRow,
) error

func CheckCSRFToken

func CheckCSRFToken(
	m shared.MetaContext,
	uid proto.UID,
	tok CSRFToken,
) error

func CheckVanityHost

func CheckVanityHost(
	m shared.MetaContext,
	user *User,
	vhr *VHostRow,
) error

func GetSessionCookie

func GetSessionCookie(
	m shared.MetaContext,
	r *http.Request,
) (
	*rem.WebSession,
	error,
)

func HandleErr

func HandleErr(
	w http.ResponseWriter,
	r *http.Request,
	err error,
)

func MakeCannedVHost

func MakeCannedVHost(
	m shared.MetaContext,
	host proto.Hostname,
	domain proto.Hostname,
) error

func NewBadParamError

func NewBadParamError(id string) error

func NewMissingParamError

func NewMissingParamError(id string) error

func Pluralize

func Pluralize(s string, n int) string

func RandomMultiUseInviteCode

func RandomMultiUseInviteCode() (*rem.MultiUseInviteCode, error)

func SetSessionCookie

func SetSessionCookie(
	m shared.MetaContext,
	w http.ResponseWriter,
	ws rem.WebSession,
) error

Types

type ActionType

type ActionType int
const (
	ActionTypeApprove ActionType = 1
	ActionTypeCancel  ActionType = 2
)

type AdminPageData

type AdminPageData struct {
	User *User

	Which PageSelector

	// Can be nil or zero-valied dedpending on how the data is loaded
	HostConfig *proto.HostConfig
	Usage      *UsageData
	AllPlans   []Plan
	ActiveSess infra.StripeSessionID
	Head       *HeaderData
	Invoices   *shared.StripeInvoices
	VHosts     *VHostData
	UserPlan   *infra.UserPlan
}

func LoadAdminPageData

func LoadAdminPageData(
	m shared.MetaContext,
	u *User,
	opts DataLoadOpts,
) (
	*AdminPageData,
	error,
)

func (*AdminPageData) CanAddMoreVHosts

func (a *AdminPageData) CanAddMoreVHosts() bool

func (*AdminPageData) CanDoSSO

func (a *AdminPageData) CanDoSSO() bool

func (*AdminPageData) GetCSRFToken

func (d *AdminPageData) GetCSRFToken() *CSRFToken

func (*AdminPageData) GetHead

func (d *AdminPageData) GetHead() *HeaderData

func (*AdminPageData) LoadUsageData

func (d *AdminPageData) LoadUsageData(m shared.MetaContext) error

func (*AdminPageData) LoadVHosts

func (d *AdminPageData) LoadVHosts(
	m shared.MetaContext,
) error

type Args

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

func NewArgs

func NewArgs(r *http.Request) *Args

func (*Args) ActionType

func (a *Args) ActionType(src ParamSource, id string) (ActionType, error)

func (*Args) Hostname

func (a *Args) Hostname(src ParamSource, id string) (proto.Hostname, error)

func (*Args) HostnamePart

func (a *Args) HostnamePart(src ParamSource, id string) (proto.Hostname, error)

func (*Args) IsChecked

func (a *Args) IsChecked(src ParamSource, id string) (bool, error)

func (*Args) MultiUseInviteCode

func (a *Args) MultiUseInviteCode(src ParamSource, id string) (*rem.MultiUseInviteCode, error)

func (*Args) NonApexHostname

func (a *Args) NonApexHostname(src ParamSource, id string) (proto.Hostname, error)

func (*Args) OAuth2SessionID

func (a *Args) OAuth2SessionID(src ParamSource, id string) (*proto.OAuth2SessionID, error)

func (*Args) PlanID

func (a *Args) PlanID(src ParamSource, id string) (*proto.PlanID, error)

func (*Args) PriceID

func (a *Args) PriceID(src ParamSource, id string) (*proto.PriceID, error)

func (*Args) SSOConfig

func (a *Args) SSOConfig(
	src ParamSource,
	providerParam string,
	urlParam string,
	idParam string,
	secretParam string,
	disableParam string,
) (*proto.SSOConfig, error)

func (*Args) StdTargetHostID

func (a *Args) StdTargetHostID() (*proto.HostID, error)

func (*Args) String

func (a *Args) String(src ParamSource, id string) (string, error)

func (*Args) StripePriceID

func (a *Args) StripePriceID(src ParamSource, id string) (*infra.StripePriceID, error)

func (*Args) StripeSessionID

func (a *Args) StripeSessionID(src ParamSource, id string) (infra.StripeSessionID, error)

func (*Args) StripeSubscriptionID

func (a *Args) StripeSubscriptionID(src ParamSource, id string) (infra.StripeSubscriptionID, error)

func (*Args) TeamID

func (a *Args) TeamID(src ParamSource, id string) (*proto.TeamID, error)

func (*Args) Time

func (a *Args) Time(src ParamSource, id string) (*proto.Time, error)

func (*Args) VHostID

func (a *Args) VHostID(src ParamSource, id string) (*proto.VHostID, error)

func (*Args) ViewershipMode

func (a *Args) ViewershipMode(src ParamSource, id string) (proto.ViewershipMode, error)

type BaseHandler

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

func NewBaseHandler

func NewBaseHandler(g *shared.GlobalContext) *BaseHandler

func NewBaseHandlerWithErr

func NewBaseHandlerWithErr(g *shared.GlobalContext, eh ErrHandler) *BaseHandler

func (*BaseHandler) Serve

func (b *BaseHandler) Serve(
	w http.ResponseWriter,
	r *http.Request,
	h func(m shared.MetaContext) error,
)

func (*BaseHandler) ServeWithVHost

func (b *BaseHandler) ServeWithVHost(
	w http.ResponseWriter,
	r *http.Request,
	h func(m shared.MetaContext) error,
)

type CSRFToken

type CSRFToken string

func CreateCSRFToken

func CreateCSRFToken(
	m shared.MetaContext,
	uid proto.UID,
) (
	CSRFToken,
	error,
)

func (CSRFToken) String

func (t CSRFToken) String() string

type DataLoadOpts

type DataLoadOpts struct {
	Which       PageSelector
	Usage       bool
	UserPlan    bool
	Plans       bool
	Sess        bool
	Headers     bool
	VHosts      bool
	DefInvoices bool
	Invoices    *shared.StripePaginate
	PageTitle   string
}

type ErrHandler

type ErrHandler func(w http.ResponseWriter, r *http.Request, err error)

type FindRowRes

type FindRowRes struct {
	Row  UsageRow
	Prev proto.EntityIDString
	Mine bool
}

type HeaderData

type HeaderData struct {
	Title string
	Nonce NoncePackage
}

func NewHeaderData

func NewHeaderData(ctx context.Context, t string) *HeaderData

type Host

type Host struct {
	core.HostID
	Name proto.Hostname
}

func LoadHostByShortID

func LoadHostByShortID(
	m shared.MetaContext,
	shid core.ShortHostID,
) (
	*Host,
	error,
)

type NoncePackage

type NoncePackage struct {
	StyleSrcElem string
	ScriptSrc    string
}

func NewNoncePackage

func NewNoncePackage() (*NoncePackage, error)

func NoncePkgFromContext

func NoncePkgFromContext(ctx context.Context) *NoncePackage

func (*NoncePackage) AddToCtx

func (n *NoncePackage) AddToCtx(ctx context.Context) context.Context

type OAuth2PageData

type OAuth2PageData struct {
	Head *HeaderData
}

func LoadOAuth2PageData

func LoadOAuth2PageData(
	m shared.MetaContext,
	opts DataLoadOpts,
) (
	*OAuth2PageData,
	error,
)

func (*OAuth2PageData) GetCSRFToken

func (d *OAuth2PageData) GetCSRFToken() *CSRFToken

func (*OAuth2PageData) GetHead

func (d *OAuth2PageData) GetHead() *HeaderData

type PageDataer

type PageDataer interface {
	GetHead() *HeaderData
	GetCSRFToken() *CSRFToken
}

type PageSelector

type PageSelector struct {
	HostType proto.HostType
	PageType PageType
}

type PageType

type PageType int
const (
	PageTypeUsage PageType = 1
	PageTypePlans PageType = 2
)

type ParamSource

type ParamSource int
const (
	ParamSourceURL   ParamSource = 1
	ParamSourceForm  ParamSource = 2
	ParamSourceQuery ParamSource = 3
)

type Plan

type Plan struct {
	infra.Plan
	Active bool
	Verb   string
	Url    string
	Ids    proto.ID16String
}

func DecoratePlans

func DecoratePlans(
	m shared.MetaContext,
	userPlan *infra.UserPlan,
	plans []infra.Plan,
) (
	[]Plan,
	error,
)

type ProrationData

type ProrationData struct {
}

type RedirectError

type RedirectError struct {
	Msg  string
	Code int
	Url  string
}

func (RedirectError) Error

func (r RedirectError) Error() string

type TypedAdminPageMain

type TypedAdminPageMain struct {
	HostType proto.HostType
}

type UsageData

type UsageData struct {
	Mine     []UsageRow
	Others   []UsageRow
	UserPlan *infra.UserPlan
	QCfg     infra.QuotaConfig
	Summary  UsageSummary
}

func LoadUsageData

func LoadUsageData(
	m shared.MetaContext,
	username proto.NameUtf8,
) (
	*UsageData,
	error,
)

func (*UsageData) CanAddMoreTeams

func (u *UsageData) CanAddMoreTeams() bool

func (*UsageData) FindRow

func (u *UsageData) FindRow(pid proto.PartyID) *FindRowRes

func (*UsageData) HasTheirs

func (u *UsageData) HasTheirs() bool

func (UsageData) MaxTeams

func (u UsageData) MaxTeams() int

type UsageRow

type UsageRow struct {
	IsTeam        bool
	Id            proto.EntityIDString
	Name          proto.NameUtf8
	Usage         proto.Size
	SrcRole       proto.Role
	DstRole       proto.Role
	IsClaimed     bool
	IsClaimedByMe bool
	// contains filtered or unexported fields
}

type UsageSummary

type UsageSummary struct {
	Total     proto.Size
	NumTeams  uint64
	OverQuota bool
}

type User

type User struct {
	Uid         proto.UID
	Name        proto.NameUtf8
	Host        *Host
	CSRFToken   CSRFToken
	AdminOfHost *core.HostID
}

func LoadUserBySession

func LoadUserBySession(
	m shared.MetaContext,
	sess rem.WebSession,
) (
	*User,
	error,
)

func LoadUserFromCookie

func LoadUserFromCookie(
	m shared.MetaContext,
	r *http.Request,
) (
	*User,
	error,
)

func (*User) CheckIsAdminOf

func (u *User) CheckIsAdminOf(m shared.MetaContext, hid proto.HostID) (*core.HostID, error)

func (*User) Email

func (u *User) Email(m shared.MetaContext) (proto.Email, error)

func (*User) LoadOrCreateCustomerID

func (u *User) LoadOrCreateCustomerID(m shared.MetaContext) (infra.StripeCustomerID, error)

func (*User) StripeCustomerID

func (u *User) StripeCustomerID(m shared.MetaContext) (infra.StripeCustomerID, error)

func (*User) ToUHC

func (u *User) ToUHC() shared.UserHostContext

type VHostAddArgs

type VHostAddArgs struct {
	IsBYOD bool // can toggle on or off
	Err    *VHostSetupError
}

type VHostCheckError

type VHostCheckError struct {
	Err error
}

func (VHostCheckError) Error

func (e VHostCheckError) Error() string

type VHostData

type VHostData struct {
	CannedDomains []proto.Hostname
	// contains filtered or unexported fields
}

func LoadVHostData

func LoadVHostData(
	m shared.MetaContext,
) (*VHostData, error)

func (*VHostData) FindVHostRow

func (v *VHostData) FindVHostRow(id proto.VHostID) *VHostRow

func (*VHostData) HasTheirs

func (v *VHostData) HasTheirs() bool

func (*VHostData) Mine

func (v *VHostData) Mine() []VHostRow

func (*VHostData) NumHosts

func (v *VHostData) NumHosts() int

func (*VHostData) Theirs

func (v *VHostData) Theirs() []VHostRow

func (*VHostData) TotalDiskUsage

func (v *VHostData) TotalDiskUsage() proto.Size

func (*VHostData) TotalUsers

func (v *VHostData) TotalUsers() uint64

type VHostRow

type VHostRow struct {
	Id            core.HostID // might be =0 if not yet complete
	VHostID       proto.VHostID
	Name          proto.Hostname
	Usage         VHostUsage
	IsClaimed     bool
	IsClaimedByMe bool
	IsCanned      bool
	Stem          proto.Hostname // If a vanity host, the CNAME stem
	Stage         proto.HostBuildStage
	Details       *VHostRowDetails
}

func (*VHostRow) LoadDetails

func (r *VHostRow) LoadDetails(m shared.MetaContext) error

type VHostRowDetails

type VHostRowDetails struct {
	MultiUseInvites   []shared.MultiUseInviteCode
	Config            proto.HostConfig
	SSO               *proto.SSOConfig
	OAuth2CallbackURL proto.URLString // this is known regardless of SSO configuration
}

func (*VHostRowDetails) FindMultiUseInviteCode

func (r *VHostRowDetails) FindMultiUseInviteCode(c rem.MultiUseInviteCode) *shared.MultiUseInviteCode

func (*VHostRowDetails) HasOAuth2SSO

func (d *VHostRowDetails) HasOAuth2SSO() bool

func (*VHostRowDetails) IsGoogleSSO added in v0.1.8

func (d *VHostRowDetails) IsGoogleSSO() bool

func (*VHostRowDetails) OAuth2SSOClientID

func (d *VHostRowDetails) OAuth2SSOClientID() string

func (*VHostRowDetails) OAuth2SSOClientSecret

func (d *VHostRowDetails) OAuth2SSOClientSecret() string

func (*VHostRowDetails) OAuth2SSOConfigURL

func (d *VHostRowDetails) OAuth2SSOConfigURL() string

func (*VHostRowDetails) OAuth2SSORedirectURI

func (d *VHostRowDetails) OAuth2SSORedirectURI() proto.URLString

type VHostSetupError

type VHostSetupError struct {
	Err error
}

func (VHostSetupError) Error

func (e VHostSetupError) Error() string

type VHostUsage

type VHostUsage struct {
	Users uint64
	Disk  proto.Size
}

func (VHostUsage) IsEmpty

func (v VHostUsage) IsEmpty() bool

type ViewershipMode

type ViewershipMode struct {
	proto.ViewershipMode
	Desc string
}

Jump to

Keyboard shortcuts

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