cts

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cts provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.8.1 DO NOT EDIT.

Index

Constants

View Source
const ServerURLRegionVariableDefault = "ap-southeast-2.aws"

ServerURLRegionVariableDefault is the default value for the `region` variable for ServerURL

Variables

This section is empty.

Functions

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func NewAuthorizeRequest

func NewAuthorizeRequest(server string, body AuthorizeJSONRequestBody) (*http.Request, error)

NewAuthorizeRequest calls the generic Authorize builder with application/json body

func NewAuthorizeRequestWithBody

func NewAuthorizeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewAuthorizeRequestWithBody constructs an http.Request for the Authorize method, with any body, and a specified content type

func NewCreateActorRequest

func NewCreateActorRequest(server string, body CreateActorJSONRequestBody) (*http.Request, error)

NewCreateActorRequest calls the generic CreateActor builder with application/json body

func NewCreateActorRequestWithBody

func NewCreateActorRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateActorRequestWithBody constructs an http.Request for the CreateActor method, with any body, and a specified content type

func NewDeleteActorRequest

func NewDeleteActorRequest(server string, actorIdentifier string, params *DeleteActorParams) (*http.Request, error)

NewDeleteActorRequest constructs an http.Request for the DeleteActor method

func NewGetJwksHandlerRequest

func NewGetJwksHandlerRequest(server string) (*http.Request, error)

NewGetJwksHandlerRequest constructs an http.Request for the GetJwksHandler method

func NewListAccessKeysRequest

func NewListAccessKeysRequest(server string, params *ListAccessKeysParams) (*http.Request, error)

NewListAccessKeysRequest constructs an http.Request for the ListAccessKeys method

func NewListActorsRequest

func NewListActorsRequest(server string, params *ListActorsParams) (*http.Request, error)

NewListActorsRequest constructs an http.Request for the ListActors method

func NewServerURL

func NewServerURL(region ServerURLRegionVariable) (string, error)

NewServerURL constructs the Server URL for CipherStash Token Service, with the provided variables.

Types

type AccessKey

type AccessKey = AccessKeyMetadata

AccessKey defines model for AccessKey.

type AccessKeyMetadata

type AccessKeyMetadata struct {
	// CreatedAt ISO 8601 timestamp when the key was created
	CreatedAt string `json:"createdAt"`

	// ID The unique identifier for this access key
	ID string `json:"keyId"`

	// Name The name of the access key
	Name string `json:"keyName"`

	// LastUsedAt ISO 8601 timestamp of the last time this key was used
	LastUsedAt *string `json:"lastUsedAt,omitempty"`

	// Role Defines a role in the system.
	Role Role `json:"role"`

	// WorkspaceID A unique identifier for a workspace.
	// Workspace IDs are 10-byte random strings formatted in base32.
	//
	// Internally, the workspace ID is stored as an [ArrayString] with a maximum length of 20 characters.
	// This means that values work entirely on the stack and implement the `Copy` trait.
	//
	// # Example
	//
	// “`
	// use cts_common::WorkspaceId;
	//
	// let workspace_id = WorkspaceId::generate().unwrap();
	// println!("Workspace ID: {}", workspace_id);
	// “`
	//
	// A [WorkspaceId] can be converted from a string but will fail if the string is not a valid workspace ID.
	//
	// “`
	// use cts_common::WorkspaceId;
	// let workspace_id = WorkspaceId::try_from("JBSWY3DPEHPK3PXP").unwrap();
	//
	// // This will fail because the string is not a valid workspace ID
	// let workspace_id = WorkspaceId::try_from("invalid-id").unwrap_err();
	// “`
	//
	// ## Comparison
	//
	// Workspace IDs can be compared to strings.
	//
	// “`
	// use cts_common::WorkspaceId;
	// let workspace_id = WorkspaceId::try_from("E4UMRN47WJNSMAKR").unwrap();
	// assert_eq!(workspace_id, "E4UMRN47WJNSMAKR");
	// “`
	//
	// ## Use with Diesel
	//
	// When the `server` feature is enabled, [WorkspaceId] can be used with Diesel in models and queries.
	// The underlying data type is a `Text` column in the database.
	WorkspaceID WorkspaceID `json:"workspaceId"`
}

AccessKeyMetadata defines model for AccessKey.

type Actor

type Actor struct {
	ID        string `json:"actorId"`
	CreatedAt string `json:"createdAt"`

	// Kind The kind of actor — determines the prefix in the serialized `ActorIdentifier`.
	Kind ActorKind `json:"kind"`
	Name string    `json:"name"`
}

Actor defines model for ActorSummary.

type ActorKind

type ActorKind string

ActorKind The kind of actor — determines the prefix in the serialized `ActorIdentifier`.

const (
	Agent ActorKind = "agent"
	App   ActorKind = "app"
)

Defines values for ActorKind.

func (ActorKind) Valid

func (e ActorKind) Valid() bool

Valid indicates whether the value is a known member of the ActorKind enum.

type ActorPage

type ActorPage struct {
	Items []ActorSummary `json:"items"`

	// NextCursor Cursor to pass as `?cursor=` on the next request. Absent on the final page.
	NextCursor string `json:"nextCursor,omitempty"`
}

ActorPage defines model for ListActorsResponse.

type ActorSummary

type ActorSummary = Actor

ActorSummary defines model for ActorSummary.

type AuthorizeHTTPResponse

type AuthorizeHTTPResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON200 the response for an HTTP 200 `application/json` response
	JSON200 *AuthorizeResponse
}

func ParseAuthorizeHTTPResponse

func ParseAuthorizeHTTPResponse(rsp *http.Response) (*AuthorizeHTTPResponse, error)

ParseAuthorizeHTTPResponse parses an HTTP response from a AuthorizeWithResponse call

func (AuthorizeHTTPResponse) ContentType

func (r AuthorizeHTTPResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (AuthorizeHTTPResponse) GetBody

func (r AuthorizeHTTPResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (AuthorizeHTTPResponse) GetJSON200

func (r AuthorizeHTTPResponse) GetJSON200() *AuthorizeResponse

GetJSON200 returns the response for an HTTP 200 `application/json` response

func (AuthorizeHTTPResponse) Status

func (r AuthorizeHTTPResponse) Status() string

Status returns HTTPResponse.Status

func (AuthorizeHTTPResponse) StatusCode

func (r AuthorizeHTTPResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type AuthorizeJSONRequestBody

type AuthorizeJSONRequestBody = AuthorizeRequest

AuthorizeJSONRequestBody defines body for Authorize for application/json ContentType.

type AuthorizeRequest

type AuthorizeRequest struct {
	// AccessKey A raw access key that has not yet been verified.
	// The wrapper ensures safe handling of the key.
	// This is useful for deserialization from JSON or other formats.
	//
	// The inner string is zeroized on drop so a full access-key credential does
	// not linger in freed memory once the `RawAccessKey` goes out of scope.
	//
	// Equality is `TimingSafeEq` (constant-time), not a plain `derive(PartialEq)`:
	// this type holds a full credential, so `==` must not leak length/prefix via
	// timing. Same choice as [`SecretToken`].
	AccessKey RawAccessKey `json:"accessKey"`

	// Audience Optional audience for the generated token. If not provided, defaults to the workspace's host FQDN.
	Audience *string `json:"audience,omitempty"`
}

AuthorizeRequest An access-key authorization request with an optional audience.

type AuthorizeResponse

type AuthorizeResponse = SignedToken

AuthorizeResponse defines model for AuthorizeResponse.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, body AuthorizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

Authorize Authorize

Exchange a credential for a CipherStash access token.

## Credential Types

This endpoint accepts two types of credentials:

### OIDC Token Exchange an OIDC JWT from a configured provider for a CipherStash token. Requires: - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace - `workspaceId`: The workspace to authorize against

### Access Key Exchange a CipherStash access key for a token. Requires: - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)

## Response

Returns a signed JWT (`accessToken`) and an `expiry` timestamp.

Takes a body of the `application/json` content type.

Corresponds with POST /api/authorise (the `Authorize` operationId).

func (*Client) AuthorizeWithBody

func (c *Client) AuthorizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

AuthorizeWithBody Authorize

Exchange a credential for a CipherStash access token.

## Credential Types

This endpoint accepts two types of credentials:

### OIDC Token Exchange an OIDC JWT from a configured provider for a CipherStash token. Requires: - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace - `workspaceId`: The workspace to authorize against

### Access Key Exchange a CipherStash access key for a token. Requires: - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)

## Response

Returns a signed JWT (`accessToken`) and an `expiry` timestamp.

Takes any type of body and a specified content type.

Corresponds with POST /api/authorise (the `Authorize` operationId).

func (*Client) CreateActor

func (c *Client) CreateActor(ctx context.Context, body CreateActorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

CreateActor Create Actor

Creates a new actor (app or agent) with an associated access key. The access key is returned once and cannot be retrieved again. Requires admin role in the workspace.

Takes a body of the `application/json` content type.

Corresponds with POST /api/actors (the `CreateActor` operationId).

func (*Client) CreateActorWithBody

func (c *Client) CreateActorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

CreateActorWithBody Create Actor

Creates a new actor (app or agent) with an associated access key. The access key is returned once and cannot be retrieved again. Requires admin role in the workspace.

Takes any type of body and a specified content type.

Corresponds with POST /api/actors (the `CreateActor` operationId).

func (*Client) DeleteActor

func (c *Client) DeleteActor(ctx context.Context, actorIdentifier string, params *DeleteActorParams, reqEditors ...RequestEditorFn) (*http.Response, error)

DeleteActor Delete Actor

Deletes an actor by its identifier. The associated access key is also deleted.

Corresponds with DELETE /api/actors/{actor_identifier} (the `DeleteActor` operationId).

func (*Client) GetJwksHandler

func (c *Client) GetJwksHandler(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

GetJwksHandler Get JSON Web Key Set

Returns the public JSON Web Key Set (JWKS) used to verify JWTs issued by this service.

Corresponds with GET /.well-known/jwks.json (the `GetJwksHandler` operationId).

func (*Client) ListAccessKeys

func (c *Client) ListAccessKeys(ctx context.Context, params *ListAccessKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error)

ListAccessKeys List Access Keys

Retrieves all access keys for the authenticated user in the specified workspace. The user must have list access key permissions.

Returns an array of access keys with metadata including creation date and last usage.

Corresponds with GET /api/access-keys (the `ListAccessKeys` operationId).

func (*Client) ListActors

func (c *Client) ListActors(ctx context.Context, params *ListActorsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

ListActors List Actors

Retrieves a page of actors for the specified workspace, newest first. Pass `nextCursor` from the response as `?cursor=` to fetch the next page.

Corresponds with GET /api/actors (the `ListActors` operationId).

type ClientInterface

type ClientInterface interface {

	// GetJwksHandler Get JSON Web Key Set
	//
	// Returns the public JSON Web Key Set (JWKS) used to verify JWTs issued by this service.
	//
	// Corresponds with GET /.well-known/jwks.json (the `GetJwksHandler` operationId).
	GetJwksHandler(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListAccessKeys List Access Keys
	//
	// Retrieves all access keys for the authenticated user in the specified workspace.
	// The user must have list access key permissions.
	//
	// Returns an array of access keys with metadata including creation date and last usage.
	//
	// Corresponds with GET /api/access-keys (the `ListAccessKeys` operationId).
	ListAccessKeys(ctx context.Context, params *ListAccessKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListActors List Actors
	//
	// Retrieves a page of actors for the specified workspace, newest first.
	// Pass `nextCursor` from the response as `?cursor=` to fetch the next page.
	//
	// Corresponds with GET /api/actors (the `ListActors` operationId).
	ListActors(ctx context.Context, params *ListActorsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// CreateActorWithBody Create Actor
	//
	// Creates a new actor (app or agent) with an associated access key.
	// The access key is returned once and cannot be retrieved again.
	// Requires admin role in the workspace.
	//
	// Takes any type of body and a specified content type.
	//
	// Corresponds with POST /api/actors (the `CreateActor` operationId).
	CreateActorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// CreateActor Create Actor
	//
	// Creates a new actor (app or agent) with an associated access key.
	// The access key is returned once and cannot be retrieved again.
	// Requires admin role in the workspace.
	//
	// Takes a body of the `application/json` content type.
	//
	// Corresponds with POST /api/actors (the `CreateActor` operationId).
	CreateActor(ctx context.Context, body CreateActorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// DeleteActor Delete Actor
	//
	// Deletes an actor by its identifier. The associated access key is also deleted.
	//
	// Corresponds with DELETE /api/actors/{actor_identifier} (the `DeleteActor` operationId).
	DeleteActor(ctx context.Context, actorIdentifier string, params *DeleteActorParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// AuthorizeWithBody Authorize
	//
	// Exchange a credential for a CipherStash access token.
	//
	// ## Credential Types
	//
	// This endpoint accepts two types of credentials:
	//
	// ### OIDC Token
	// Exchange an OIDC JWT from a configured provider for a CipherStash token.
	// Requires:
	// - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace
	// - `workspaceId`: The workspace to authorize against
	//
	// ### Access Key
	// Exchange a CipherStash access key for a token.
	// Requires:
	// - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)
	//
	// ## Response
	//
	// Returns a signed JWT (`accessToken`) and an `expiry` timestamp.
	//
	// Takes any type of body and a specified content type.
	//
	// Corresponds with POST /api/authorise (the `Authorize` operationId).
	AuthorizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// Authorize Authorize
	//
	// Exchange a credential for a CipherStash access token.
	//
	// ## Credential Types
	//
	// This endpoint accepts two types of credentials:
	//
	// ### OIDC Token
	// Exchange an OIDC JWT from a configured provider for a CipherStash token.
	// Requires:
	// - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace
	// - `workspaceId`: The workspace to authorize against
	//
	// ### Access Key
	// Exchange a CipherStash access key for a token.
	// Requires:
	// - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)
	//
	// ## Response
	//
	// Returns a signed JWT (`accessToken`) and an `expiry` timestamp.
	//
	// Takes a body of the `application/json` content type.
	//
	// Corresponds with POST /api/authorise (the `Authorize` operationId).
	Authorize(ctx context.Context, body AuthorizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) AuthorizeWithBodyWithResponse

func (c *ClientWithResponses) AuthorizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthorizeHTTPResponse, error)

AuthorizeWithBodyWithResponse Authorize

Exchange a credential for a CipherStash access token.

## Credential Types

This endpoint accepts two types of credentials:

### OIDC Token Exchange an OIDC JWT from a configured provider for a CipherStash token. Requires: - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace - `workspaceId`: The workspace to authorize against

### Access Key Exchange a CipherStash access key for a token. Requires: - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)

## Response

Returns a signed JWT (`accessToken`) and an `expiry` timestamp.

Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /api/authorise (the `Authorize` operationId).

func (*ClientWithResponses) AuthorizeWithResponse

func (c *ClientWithResponses) AuthorizeWithResponse(ctx context.Context, body AuthorizeJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthorizeHTTPResponse, error)

AuthorizeWithResponse Authorize

Exchange a credential for a CipherStash access token.

## Credential Types

This endpoint accepts two types of credentials:

### OIDC Token Exchange an OIDC JWT from a configured provider for a CipherStash token. Requires: - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace - `workspaceId`: The workspace to authorize against

### Access Key Exchange a CipherStash access key for a token. Requires: - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)

## Response

Returns a signed JWT (`accessToken`) and an `expiry` timestamp.

Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /api/authorise (the `Authorize` operationId).

func (*ClientWithResponses) CreateActorWithBodyWithResponse

func (c *ClientWithResponses) CreateActorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateActorHTTPResponse, error)

CreateActorWithBodyWithResponse Create Actor

Creates a new actor (app or agent) with an associated access key. The access key is returned once and cannot be retrieved again. Requires admin role in the workspace.

Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /api/actors (the `CreateActor` operationId).

func (*ClientWithResponses) CreateActorWithResponse

func (c *ClientWithResponses) CreateActorWithResponse(ctx context.Context, body CreateActorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateActorHTTPResponse, error)

CreateActorWithResponse Create Actor

Creates a new actor (app or agent) with an associated access key. The access key is returned once and cannot be retrieved again. Requires admin role in the workspace.

Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /api/actors (the `CreateActor` operationId).

func (*ClientWithResponses) DeleteActorWithResponse

func (c *ClientWithResponses) DeleteActorWithResponse(ctx context.Context, actorIdentifier string, params *DeleteActorParams, reqEditors ...RequestEditorFn) (*DeleteActorHTTPResponse, error)

DeleteActorWithResponse Delete Actor

Deletes an actor by its identifier. The associated access key is also deleted.

Returns a wrapper object for the known response body format(s).

Corresponds with DELETE /api/actors/{actor_identifier} (the `DeleteActor` operationId).

func (*ClientWithResponses) GetJwksHandlerWithResponse

func (c *ClientWithResponses) GetJwksHandlerWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetJwksHandlerHTTPResponse, error)

GetJwksHandlerWithResponse Get JSON Web Key Set

Returns the public JSON Web Key Set (JWKS) used to verify JWTs issued by this service.

Returns a wrapper object for the known response body format(s).

Corresponds with GET /.well-known/jwks.json (the `GetJwksHandler` operationId).

func (*ClientWithResponses) ListAccessKeysWithResponse

func (c *ClientWithResponses) ListAccessKeysWithResponse(ctx context.Context, params *ListAccessKeysParams, reqEditors ...RequestEditorFn) (*ListAccessKeysHTTPResponse, error)

ListAccessKeysWithResponse List Access Keys

Retrieves all access keys for the authenticated user in the specified workspace. The user must have list access key permissions.

Returns an array of access keys with metadata including creation date and last usage.

Returns a wrapper object for the known response body format(s).

Corresponds with GET /api/access-keys (the `ListAccessKeys` operationId).

func (*ClientWithResponses) ListActorsWithResponse

func (c *ClientWithResponses) ListActorsWithResponse(ctx context.Context, params *ListActorsParams, reqEditors ...RequestEditorFn) (*ListActorsHTTPResponse, error)

ListActorsWithResponse List Actors

Retrieves a page of actors for the specified workspace, newest first. Pass `nextCursor` from the response as `?cursor=` to fetch the next page.

Returns a wrapper object for the known response body format(s).

Corresponds with GET /api/actors (the `ListActors` operationId).

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {

	// GetJwksHandlerWithResponse Get JSON Web Key Set
	//
	// Returns the public JSON Web Key Set (JWKS) used to verify JWTs issued by this service.
	//
	// Returns a wrapper object for the known response body format(s).
	//
	// Corresponds with GET /.well-known/jwks.json (the `GetJwksHandler` operationId).
	GetJwksHandlerWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetJwksHandlerHTTPResponse, error)

	// ListAccessKeysWithResponse List Access Keys
	//
	// Retrieves all access keys for the authenticated user in the specified workspace.
	// The user must have list access key permissions.
	//
	// Returns an array of access keys with metadata including creation date and last usage.
	//
	// Returns a wrapper object for the known response body format(s).
	//
	// Corresponds with GET /api/access-keys (the `ListAccessKeys` operationId).
	ListAccessKeysWithResponse(ctx context.Context, params *ListAccessKeysParams, reqEditors ...RequestEditorFn) (*ListAccessKeysHTTPResponse, error)

	// ListActorsWithResponse List Actors
	//
	// Retrieves a page of actors for the specified workspace, newest first.
	// Pass `nextCursor` from the response as `?cursor=` to fetch the next page.
	//
	// Returns a wrapper object for the known response body format(s).
	//
	// Corresponds with GET /api/actors (the `ListActors` operationId).
	ListActorsWithResponse(ctx context.Context, params *ListActorsParams, reqEditors ...RequestEditorFn) (*ListActorsHTTPResponse, error)

	// CreateActorWithBodyWithResponse Create Actor
	//
	// Creates a new actor (app or agent) with an associated access key.
	// The access key is returned once and cannot be retrieved again.
	// Requires admin role in the workspace.
	//
	// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /api/actors (the `CreateActor` operationId).
	CreateActorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateActorHTTPResponse, error)

	// CreateActorWithResponse Create Actor
	//
	// Creates a new actor (app or agent) with an associated access key.
	// The access key is returned once and cannot be retrieved again.
	// Requires admin role in the workspace.
	//
	// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /api/actors (the `CreateActor` operationId).
	CreateActorWithResponse(ctx context.Context, body CreateActorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateActorHTTPResponse, error)

	// DeleteActorWithResponse Delete Actor
	//
	// Deletes an actor by its identifier. The associated access key is also deleted.
	//
	// Returns a wrapper object for the known response body format(s).
	//
	// Corresponds with DELETE /api/actors/{actor_identifier} (the `DeleteActor` operationId).
	DeleteActorWithResponse(ctx context.Context, actorIdentifier string, params *DeleteActorParams, reqEditors ...RequestEditorFn) (*DeleteActorHTTPResponse, error)

	// AuthorizeWithBodyWithResponse Authorize
	//
	// Exchange a credential for a CipherStash access token.
	//
	// ## Credential Types
	//
	// This endpoint accepts two types of credentials:
	//
	// ### OIDC Token
	// Exchange an OIDC JWT from a configured provider for a CipherStash token.
	// Requires:
	// - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace
	// - `workspaceId`: The workspace to authorize against
	//
	// ### Access Key
	// Exchange a CipherStash access key for a token.
	// Requires:
	// - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)
	//
	// ## Response
	//
	// Returns a signed JWT (`accessToken`) and an `expiry` timestamp.
	//
	// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /api/authorise (the `Authorize` operationId).
	AuthorizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthorizeHTTPResponse, error)

	// AuthorizeWithResponse Authorize
	//
	// Exchange a credential for a CipherStash access token.
	//
	// ## Credential Types
	//
	// This endpoint accepts two types of credentials:
	//
	// ### OIDC Token
	// Exchange an OIDC JWT from a configured provider for a CipherStash token.
	// Requires:
	// - `oidcToken`: A valid JWT from an OIDC provider configured for the workspace
	// - `workspaceId`: The workspace to authorize against
	//
	// ### Access Key
	// Exchange a CipherStash access key for a token.
	// Requires:
	// - `accessKey`: A valid CipherStash access key (format: `CSAKT...`)
	//
	// ## Response
	//
	// Returns a signed JWT (`accessToken`) and an `expiry` timestamp.
	//
	// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /api/authorise (the `Authorize` operationId).
	AuthorizeWithResponse(ctx context.Context, body AuthorizeJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthorizeHTTPResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type CreateActorHTTPResponse

type CreateActorHTTPResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON201 the response for an HTTP 201 `application/json` response
	JSON201 *CreateActorResponse
}

func ParseCreateActorHTTPResponse

func ParseCreateActorHTTPResponse(rsp *http.Response) (*CreateActorHTTPResponse, error)

ParseCreateActorHTTPResponse parses an HTTP response from a CreateActorWithResponse call

func (CreateActorHTTPResponse) ContentType

func (r CreateActorHTTPResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (CreateActorHTTPResponse) GetBody

func (r CreateActorHTTPResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (CreateActorHTTPResponse) GetJSON201

GetJSON201 returns the response for an HTTP 201 `application/json` response

func (CreateActorHTTPResponse) Status

func (r CreateActorHTTPResponse) Status() string

Status returns HTTPResponse.Status

func (CreateActorHTTPResponse) StatusCode

func (r CreateActorHTTPResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type CreateActorJSONRequestBody

type CreateActorJSONRequestBody = CreateActorRequest

CreateActorJSONRequestBody defines body for CreateActor for application/json ContentType.

type CreateActorOptions

type CreateActorOptions struct {
	// Kind The kind of actor — determines the prefix in the serialized `ActorIdentifier`.
	Kind ActorKind `json:"kind"`

	// Name A human-readable name for the actor, unique within the workspace.
	Name string `json:"name"`
	Role Role   `json:"role,omitempty"`

	// TokenExpiry Optional TTL in seconds for tokens issued with this actor's access key.
	TokenExpiry *int64 `json:"tokenExpiry,omitempty"`
}

CreateActorOptions defines model for CreateActorRequest.

type CreateActorRequest

type CreateActorRequest = CreateActorOptions

CreateActorRequest defines model for CreateActorRequest.

type CreateActorResponse

type CreateActorResponse struct {
	// AccessKey A raw access key that has not yet been verified.
	// The wrapper ensures safe handling of the key.
	// This is useful for deserialization from JSON or other formats.
	//
	// The inner string is zeroized on drop so a full access-key credential does
	// not linger in freed memory once the `RawAccessKey` goes out of scope.
	//
	// Equality is `TimingSafeEq` (constant-time), not a plain `derive(PartialEq)`:
	// this type holds a full credential, so `==` must not leak length/prefix via
	// timing. Same choice as [`SecretToken`].
	AccessKey RawAccessKey `json:"accessKey"`
	ActorID   string       `json:"actorId"`

	// Kind The kind of actor — determines the prefix in the serialized `ActorIdentifier`.
	Kind ActorKind `json:"kind"`
	Name string    `json:"name"`

	// Role Defines a role in the system.
	Role Role `json:"role"`
}

CreateActorResponse defines model for CreateActorResponse.

type DeleteActorHTTPResponse

type DeleteActorHTTPResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON200 the response for an HTTP 200 `application/json` response
	JSON200 *DeleteActorResponse
}

func ParseDeleteActorHTTPResponse

func ParseDeleteActorHTTPResponse(rsp *http.Response) (*DeleteActorHTTPResponse, error)

ParseDeleteActorHTTPResponse parses an HTTP response from a DeleteActorWithResponse call

func (DeleteActorHTTPResponse) ContentType

func (r DeleteActorHTTPResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (DeleteActorHTTPResponse) GetBody

func (r DeleteActorHTTPResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (DeleteActorHTTPResponse) GetJSON200

GetJSON200 returns the response for an HTTP 200 `application/json` response

func (DeleteActorHTTPResponse) Status

func (r DeleteActorHTTPResponse) Status() string

Status returns HTTPResponse.Status

func (DeleteActorHTTPResponse) StatusCode

func (r DeleteActorHTTPResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type DeleteActorParams

type DeleteActorParams struct {
	XCsWorkspaceID WorkspaceID `json:"x-cs-workspace-id"`
}

DeleteActorParams defines parameters for DeleteActor.

type DeleteActorResponse

type DeleteActorResponse struct {
	Message string `json:"message"`
}

DeleteActorResponse defines model for DeleteActorResponse.

type GetJwksHandlerHTTPResponse

type GetJwksHandlerHTTPResponse struct {
	Body         []byte
	HTTPResponse *http.Response
}

func ParseGetJwksHandlerHTTPResponse

func ParseGetJwksHandlerHTTPResponse(rsp *http.Response) (*GetJwksHandlerHTTPResponse, error)

ParseGetJwksHandlerHTTPResponse parses an HTTP response from a GetJwksHandlerWithResponse call

func (GetJwksHandlerHTTPResponse) ContentType

func (r GetJwksHandlerHTTPResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (GetJwksHandlerHTTPResponse) GetBody

func (r GetJwksHandlerHTTPResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (GetJwksHandlerHTTPResponse) Status

Status returns HTTPResponse.Status

func (GetJwksHandlerHTTPResponse) StatusCode

func (r GetJwksHandlerHTTPResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type ListAccessKeysHTTPResponse

type ListAccessKeysHTTPResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON200 the response for an HTTP 200 `application/json` response
	JSON200 *[]AccessKey
}

func ParseListAccessKeysHTTPResponse

func ParseListAccessKeysHTTPResponse(rsp *http.Response) (*ListAccessKeysHTTPResponse, error)

ParseListAccessKeysHTTPResponse parses an HTTP response from a ListAccessKeysWithResponse call

func (ListAccessKeysHTTPResponse) ContentType

func (r ListAccessKeysHTTPResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (ListAccessKeysHTTPResponse) GetBody

func (r ListAccessKeysHTTPResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (ListAccessKeysHTTPResponse) GetJSON200

func (r ListAccessKeysHTTPResponse) GetJSON200() *[]AccessKey

GetJSON200 returns the response for an HTTP 200 `application/json` response

func (ListAccessKeysHTTPResponse) Status

Status returns HTTPResponse.Status

func (ListAccessKeysHTTPResponse) StatusCode

func (r ListAccessKeysHTTPResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ListAccessKeysParams

type ListAccessKeysParams struct {
	XCsWorkspaceID WorkspaceID `json:"x-cs-workspace-id"`
}

ListAccessKeysParams defines parameters for ListAccessKeys.

type ListActorsHTTPResponse

type ListActorsHTTPResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON200 the response for an HTTP 200 `application/json` response
	JSON200 *ListActorsResponse
}

func ParseListActorsHTTPResponse

func ParseListActorsHTTPResponse(rsp *http.Response) (*ListActorsHTTPResponse, error)

ParseListActorsHTTPResponse parses an HTTP response from a ListActorsWithResponse call

func (ListActorsHTTPResponse) ContentType

func (r ListActorsHTTPResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (ListActorsHTTPResponse) GetBody

func (r ListActorsHTTPResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (ListActorsHTTPResponse) GetJSON200

GetJSON200 returns the response for an HTTP 200 `application/json` response

func (ListActorsHTTPResponse) Status

func (r ListActorsHTTPResponse) Status() string

Status returns HTTPResponse.Status

func (ListActorsHTTPResponse) StatusCode

func (r ListActorsHTTPResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ListActorsParams

type ListActorsParams struct {
	// Limit Maximum actors to return. Clamped to `[1, 200]`; defaults to 50.
	Limit *int `form:"limit,omitempty" json:"limit,omitempty"`

	// Cursor Opaque cursor returned as `nextCursor` from a previous page.
	Cursor         *string     `form:"cursor,omitempty" json:"cursor,omitempty"`
	XCsWorkspaceID WorkspaceID `json:"x-cs-workspace-id"`
}

ListActorsParams defines parameters for ListActors.

type ListActorsResponse

type ListActorsResponse = ActorPage

ListActorsResponse defines model for ListActorsResponse.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type RawAccessKey

type RawAccessKey = string

RawAccessKey A raw access key that has not yet been verified. The wrapper ensures safe handling of the key. This is useful for deserialization from JSON or other formats.

The inner string is zeroized on drop so a full access-key credential does not linger in freed memory once the `RawAccessKey` goes out of scope.

Equality is `TimingSafeEq` (constant-time), not a plain `derive(PartialEq)`: this type holds a full credential, so `==` must not leak length/prefix via timing. Same choice as [`SecretToken`].

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type Role

type Role string

Role Defines a role in the system.

const (
	Admin   Role = "admin"
	Control Role = "control"
	Member  Role = "member"
)

Defines values for Role.

func (Role) Valid

func (e Role) Valid() bool

Valid indicates whether the value is a known member of the Role enum.

type ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	http.Handler
}

ServeMux is an abstraction of http.ServeMux.

type ServerInterface

type ServerInterface interface {
	// GetJwksHandler Get JSON Web Key Set
	// (GET /.well-known/jwks.json)
	GetJwksHandler(w http.ResponseWriter, r *http.Request)
	// ListAccessKeys List Access Keys
	// (GET /api/access-keys)
	ListAccessKeys(w http.ResponseWriter, r *http.Request, params ListAccessKeysParams)
	// ListActors List Actors
	// (GET /api/actors)
	ListActors(w http.ResponseWriter, r *http.Request, params ListActorsParams)
	// CreateActor Create Actor
	// (POST /api/actors)
	CreateActor(w http.ResponseWriter, r *http.Request)
	// DeleteActor Delete Actor
	// (DELETE /api/actors/{actor_identifier})
	DeleteActor(w http.ResponseWriter, r *http.Request, actorIdentifier string, params DeleteActorParams)
	// Authorize Authorize
	// (POST /api/authorise)
	Authorize(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) Authorize

func (siw *ServerInterfaceWrapper) Authorize(w http.ResponseWriter, r *http.Request)

Authorize operation middleware

func (*ServerInterfaceWrapper) CreateActor

func (siw *ServerInterfaceWrapper) CreateActor(w http.ResponseWriter, r *http.Request)

CreateActor operation middleware

func (*ServerInterfaceWrapper) DeleteActor

func (siw *ServerInterfaceWrapper) DeleteActor(w http.ResponseWriter, r *http.Request)

DeleteActor operation middleware

func (*ServerInterfaceWrapper) GetJwksHandler

func (siw *ServerInterfaceWrapper) GetJwksHandler(w http.ResponseWriter, r *http.Request)

GetJwksHandler operation middleware

func (*ServerInterfaceWrapper) ListAccessKeys

func (siw *ServerInterfaceWrapper) ListAccessKeys(w http.ResponseWriter, r *http.Request)

ListAccessKeys operation middleware

func (*ServerInterfaceWrapper) ListActors

func (siw *ServerInterfaceWrapper) ListActors(w http.ResponseWriter, r *http.Request)

ListActors operation middleware

type ServerURLRegionVariable

type ServerURLRegionVariable string

ServerURLRegionVariable is the `region` variable for ServerURL

type SignedToken

type SignedToken struct {
	AccessToken string `json:"accessToken"`
	Expiry      int64  `json:"expiry"`
}

SignedToken defines model for SignedToken.

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type WorkspaceID

type WorkspaceID = string

WorkspaceID A unique identifier for a workspace. Workspace IDs are 10-byte random strings formatted in base32.

Internally, the workspace ID is stored as an [ArrayString] with a maximum length of 20 characters. This means that values work entirely on the stack and implement the `Copy` trait.

Example

``` use cts_common::WorkspaceId;

let workspace_id = WorkspaceId::generate().unwrap(); println!("Workspace ID: {}", workspace_id); ```

A [WorkspaceId] can be converted from a string but will fail if the string is not a valid workspace ID.

``` use cts_common::WorkspaceId; let workspace_id = WorkspaceId::try_from("JBSWY3DPEHPK3PXP").unwrap();

// This will fail because the string is not a valid workspace ID let workspace_id = WorkspaceId::try_from("invalid-id").unwrap_err(); ```

## Comparison

Workspace IDs can be compared to strings.

``` use cts_common::WorkspaceId; let workspace_id = WorkspaceId::try_from("E4UMRN47WJNSMAKR").unwrap(); assert_eq!(workspace_id, "E4UMRN47WJNSMAKR"); ```

## Use with Diesel

When the `server` feature is enabled, [WorkspaceId] can be used with Diesel in models and queries. The underlying data type is a `Text` column in the database.

Jump to

Keyboard shortcuts

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