Documentation
¶
Overview ¶
Package client is the REST client of the graphnest command-line tool.
Index ¶
- func NewSecret() string
- func Origin(serverURL string) (string, error)
- func RevokeLogin(ctx context.Context, config Config, login Login) error
- func StripControl(s string) string
- type Client
- func (c *Client) GraphStatus(ctx context.Context, id int64) (api.GraphStatus, error)
- func (c *Client) Publish(ctx context.Context, id int64, commit string, expectedGeneration int64, ...) (api.GraphPublicationResult, error)
- func (c *Client) Repository(ctx context.Context, id int64) (api.RepositorySummary, error)
- type Config
- type Error
- type Login
- type Logins
- type OAuth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSecret ¶ added in v0.11.0
func NewSecret() string
NewSecret returns 32 random bytes as 43 base64url characters, for PKCE verifiers and state.
func Origin ¶ added in v0.11.0
Origin returns the scheme and lower-cased host of an http or https URL.
func RevokeLogin ¶ added in v0.11.0
RevokeLogin revokes the login's refresh token (RFC 7009).
func StripControl ¶ added in v0.11.0
StripControl drops control characters from server-provided text before it reaches a terminal.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a GraphNest server with a bearer token.
func (*Client) GraphStatus ¶
GraphStatus fetches GET /v1/graph/repositories/{id}/status.
func (*Client) Publish ¶
func (c *Client) Publish(ctx context.Context, id int64, commit string, expectedGeneration int64, replaceProducer bool, artifact []byte) (api.GraphPublicationResult, error)
Publish uploads a v2 graph artifact.
func (*Client) Repository ¶
Repository fetches GET /v1/repositories/{id}.
type Config ¶
type Config struct {
ServerURL string // GRAPHNEST_SERVER_URL, required, http or https
Token string // GRAPHNEST_TOKEN, or the trimmed contents of the file named by GRAPHNEST_TOKEN_FILE; at most one may be set; without either, Login supplies the credential
CAPEM []byte // contents of GRAPHNEST_CA_FILE when set
Timeout time.Duration // whole-request timeout; zero means 2 minutes
Login *Login // stored OAuth login used instead of Token
Logins Logins // where a refreshed Login is saved
Source string // where the credential came from: "GRAPHNEST_TOKEN", "GRAPHNEST_TOKEN_FILE" or "stored login"
}
Config comes from the environment and the stored login only; a token never comes from arguments.
type Login ¶ added in v0.11.0
type Login struct {
Server string `json:"server"`
ClientID string `json:"client_id"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresAt time.Time `json:"expires_at"`
TokenEndpoint string `json:"token_endpoint"`
RevocationEndpoint string `json:"revocation_endpoint,omitempty"`
}
Login is a stored OAuth sign-in for one GraphNest server.
type Logins ¶ added in v0.11.0
type Logins struct{ Dir string }
Logins stores one <hex sha256(origin)>.json file per server in Dir. The zero value stores nothing.
func (Logins) Delete ¶ added in v0.11.0
Delete removes the stored login for origin; a missing file is not an error.
type OAuth ¶ added in v0.11.0
type OAuth struct {
// contains filtered or unexported fields
}
OAuth talks to one authorization server whose issuer was verified against the server origin.
func DiscoverOAuth ¶ added in v0.11.0
DiscoverOAuth fetches RFC 8414 metadata from the origin of config.ServerURL and checks issuer, PKCE S256 and endpoints.
func (*OAuth) AuthorizationURL ¶ added in v0.11.0
AuthorizationURL builds the authorization request with an S256 challenge for verifier.