stackauth

package
v0.1.117 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAPIURL = "https://api.stack-auth.com/api/v1"

Variables

This section is empty.

Functions

func HTTPErrorCode added in v0.1.62

func HTTPErrorCode(err error) string

HTTPErrorCode returns Stack's machine-readable error code, when present.

func HTTPStatus added in v0.1.62

func HTTPStatus(err error) (int, bool)

HTTPStatus returns the response status carried by a Stack API error. Callers should use this instead of parsing Stack's human-readable response body, which is not a stable interface.

func Retryable

func Retryable(err error) bool

Retryable reports whether a failed Stack request is safe to retry while an existing CLI login deadline and context still bound the operation.

Types

type CLIPoll

type CLIPoll struct {
	Status       string `json:"status"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

type CLIStart

type CLIStart struct {
	PollingCode string    `json:"polling_code"`
	LoginCode   string    `json:"login_code"`
	ExpiresAt   time.Time `json:"-"`
}

func (*CLIStart) UnmarshalJSON

func (s *CLIStart) UnmarshalJSON(body []byte) error

type Claims

type Claims struct {
	Subject        string
	ProjectID      string
	SelectedTeamID string
	Email          string
	Role           string
	Issuer         string
	ExpiresAt      time.Time
	IsAnonymous    bool
	IsRestricted   bool
}

func ParseClaimsUnverified

func ParseClaimsUnverified(token string) (Claims, error)

ParseClaimsUnverified reads identity hints used to select the user's team in the CLI. The hosted service independently verifies the signature and every security-sensitive claim before issuing a tenant key.

type Client

type Client struct {
	APIURL               string
	ProjectID            string
	PublishableClientKey string
	HTTPClient           *http.Client
}

func (Client) ListTeams

func (c Client) ListTeams(ctx context.Context, accessToken string) ([]Team, error)

func (Client) PollCLI

func (c Client) PollCLI(ctx context.Context, pollingCode string) (CLIPoll, error)

func (Client) Refresh

func (c Client) Refresh(ctx context.Context, refreshToken string) (SessionTokens, error)

func (Client) SelectTeam

func (c Client) SelectTeam(ctx context.Context, accessToken, teamID string) error

func (Client) SignOut

func (c Client) SignOut(ctx context.Context, accessToken, refreshToken string) error

func (Client) StartCLI

func (c Client) StartCLI(ctx context.Context, expires time.Duration) (CLIStart, error)

type HTTPError

type HTTPError struct {
	Action     string
	StatusCode int
	Code       string
	Message    string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type PublicConfig

type PublicConfig struct {
	Version int `json:"version"`
	Auth    struct {
		APIURL               string `json:"apiUrl"`
		ProjectID            string `json:"projectId"`
		PublishableClientKey string `json:"publishableClientKey"`
		ConfirmURL           string `json:"confirmUrl"`
	} `json:"auth"`
	Subrouter struct {
		URL         string `json:"url"`
		ExchangeURL string `json:"exchangeUrl"`
	} `json:"subrouter"`
}

func FetchPublicConfig

func FetchPublicConfig(ctx context.Context, httpClient *http.Client, cmuxBaseURL string) (PublicConfig, error)

func (PublicConfig) Validate

func (c PublicConfig) Validate() error

type SessionTokens

type SessionTokens struct {
	AccessToken  string
	RefreshToken string
}

type Team

type Team struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
}

type TenantExchange

type TenantExchange struct {
	TenantID     string   `json:"tenantId"`
	TenantName   string   `json:"tenantName"`
	TenantKey    string   `json:"tenantKey"`
	ProxyURL     string   `json:"proxyUrl"`
	Capabilities []string `json:"capabilities"`
}

func ExchangeTenant

func ExchangeTenant(
	ctx context.Context,
	httpClient *http.Client,
	exchangeURL string,
	accessToken string,
	refreshToken string,
	teamID string,
	teamName string,
) (TenantExchange, error)

type Verifier

type Verifier struct {
	APIURL     string
	ProjectID  string
	HTTPClient *http.Client
	CacheTTL   time.Duration
	// ForceRefreshInterval bounds signature-triggered JWKS refreshes.
	ForceRefreshInterval time.Duration
	Now                  func() time.Time
	// contains filtered or unexported fields
}

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, token string) (Claims, error)

Jump to

Keyboard shortcuts

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