Documentation
¶
Index ¶
- Variables
- type AuthClient
- func (c *AuthClient) CreateCIToken(ctx context.Context, name string, scopes []string, expiresAt time.Time) (*CreatedCIToken, error)
- func (c *AuthClient) CreateOrganization(ctx context.Context, name string, slug *string) (*Organization, error)
- func (c *AuthClient) GetMe(ctx context.Context) (*Me, error)
- func (c *AuthClient) ListCITokenScopes(ctx context.Context) ([]CITokenScope, error)
- func (c *AuthClient) ListCITokens(ctx context.Context) ([]CIToken, error)
- func (c *AuthClient) ListOrganizations(ctx context.Context) ([]Organization, error)
- func (c *AuthClient) ListSessions(ctx context.Context) ([]Session, error)
- func (c *AuthClient) RevokeCIToken(ctx context.Context, id string) (*CIToken, error)
- func (c *AuthClient) RevokeOtherSessions(ctx context.Context) (int64, error)
- func (c *AuthClient) RevokeSession(ctx context.Context, id string) error
- type CIToken
- type CITokenScope
- type CreatedCIToken
- type Me
- type Organization
- type Session
- type SessionClient
Constants ¶
This section is empty.
Variables ¶
ErrUnauthorized is returned when the API rejects our token. Higher-level commands can suggest re-running `norcube login`.
Functions ¶
This section is empty.
Types ¶
type AuthClient ¶
type AuthClient struct {
BaseURL string
HTTP *http.Client
Token func(ctx context.Context) (string, error)
}
AuthClient talks to the auth service (/auth/me, /organizations, ...). It expects the caller to provide a valid Bearer token via Authorization.
func NewAuthClient ¶
func (*AuthClient) CreateCIToken ¶ added in v0.18.0
func (c *AuthClient) CreateCIToken(ctx context.Context, name string, scopes []string, expiresAt time.Time) (*CreatedCIToken, error)
CreateCIToken creates a CI token in the organization and returns it with its secret.
func (*AuthClient) CreateOrganization ¶
func (c *AuthClient) CreateOrganization(ctx context.Context, name string, slug *string) (*Organization, error)
CreateOrganization creates a new org with the given name. slug is optional — when nil or empty the server derives one from the name. The caller becomes the owner. Returns the new org's id, slug, and canonicalised name.
The server returns the new org wrapped in {"organization": {...}} — we unwrap so the caller gets the same Organization shape that ListOrganizations hands back.
func (*AuthClient) ListCITokenScopes ¶ added in v0.18.0
func (c *AuthClient) ListCITokenScopes(ctx context.Context) ([]CITokenScope, error)
ListCITokenScopes lists every CI token scope and whether the caller may grant it.
func (*AuthClient) ListCITokens ¶ added in v0.18.0
func (c *AuthClient) ListCITokens(ctx context.Context) ([]CIToken, error)
ListCITokens lists the organization's CI tokens (the organization of the client's token).
func (*AuthClient) ListOrganizations ¶
func (c *AuthClient) ListOrganizations(ctx context.Context) ([]Organization, error)
func (*AuthClient) ListSessions ¶ added in v0.16.0
func (c *AuthClient) ListSessions(ctx context.Context) ([]Session, error)
ListSessions lists the caller's live CLI sessions, most recently used first.
func (*AuthClient) RevokeCIToken ¶ added in v0.18.0
RevokeCIToken revokes a CI token; revoking a revoked token is a no-op.
func (*AuthClient) RevokeOtherSessions ¶ added in v0.16.0
func (c *AuthClient) RevokeOtherSessions(ctx context.Context) (int64, error)
RevokeOtherSessions ends every session of the caller except the one the request's own token belongs to, and returns how many it ended.
func (*AuthClient) RevokeSession ¶ added in v0.16.0
func (c *AuthClient) RevokeSession(ctx context.Context, id string) error
RevokeSession ends one of the caller's sessions. Idempotent for the caller's own sessions; an unknown id is a not-found error.
type CIToken ¶ added in v0.18.0
type CIToken struct {
ID string `json:"id"`
Name string `json:"name"`
Preview string `json:"preview"`
Scopes []string `json:"scopes"`
CreatedBy *string `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
LastUsedAt *time.Time `json:"last_used_at"`
LastUsedIP *string `json:"last_used_ip"`
RevokedAt *time.Time `json:"revoked_at"`
// Status is active, expired or revoked.
Status string `json:"status"`
}
CIToken is an organization's CI token as Norcube Auth lists it. The secret itself is only ever returned once, by CreateCIToken.
type CITokenScope ¶ added in v0.18.0
type CITokenScope struct {
Scope string `json:"scope"`
Label string `json:"label"`
Description string `json:"description"`
Product string `json:"product"`
Write bool `json:"write"`
Available bool `json:"available"`
}
CITokenScope is a scope a CI token can carry, and whether the caller's role allows granting it.
type CreatedCIToken ¶ added in v0.18.0
CreatedCIToken is a new CI token plus its secret, shown once.
type Organization ¶
type Session ¶ added in v0.16.0
type Session struct {
ID string `json:"id"`
Kind string `json:"kind"`
Hostname *string `json:"hostname"`
Client SessionClient `json:"client"`
IPAddress *string `json:"ip_address"`
CreatedAt time.Time `json:"created_at"`
LastUsedAt time.Time `json:"last_used_at"`
ExpiresAt time.Time `json:"expires_at"`
// Current marks the session the request's own token belongs to.
Current bool `json:"current"`
// OAuthGrantID and Scopes describe an OAuth sign-in; both are null
// for the older sign-in, which always has full access.
OAuthGrantID *string `json:"oauth_grant_id,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}
Session is one signed-in CLI session of the caller (GET /auth/me/sessions).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apierror renders non-2xx API responses into error messages that are actually useful for debugging.
|
Package apierror renders non-2xx API responses into error messages that are actually useful for debugging. |
|
Package billing provides primitives to interact with the openapi HTTP API.
|
Package billing provides primitives to interact with the openapi HTTP API. |
|
Package domainradar provides primitives to interact with the openapi HTTP API.
|
Package domainradar provides primitives to interact with the openapi HTTP API. |
|
Package langsync provides primitives to interact with the openapi HTTP API.
|
Package langsync provides primitives to interact with the openapi HTTP API. |
|
Package monitor provides primitives to interact with the openapi HTTP API.
|
Package monitor provides primitives to interact with the openapi HTTP API. |
|
Package snapdb provides primitives to interact with the openapi HTTP API.
|
Package snapdb provides primitives to interact with the openapi HTTP API. |