Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidWebhookRequest is returned when the given webhook request is not valid. ErrInvalidWebhookRequest = errors.New("invalid authorization webhook request") // ErrInvalidWebhookResponse is returned when the given webhook response is not valid. ErrInvalidWebhookResponse = errors.New("invalid authorization webhook response") )
var ( // ErrInvalidID is returned when the given ID is not ObjectID. ErrInvalidID = errors.New("invalid ID") )
Functions ¶
func IsAuthMethod ¶
IsAuthMethod returns whether the given method can be used for authorization.
Types ¶
type AccessAttribute ¶
AccessAttribute represents an access attribute.
type AccessInfo ¶
type AccessInfo struct { Method Method Attributes []AccessAttribute }
AccessInfo represents an access information.
type AuthWebhookRequest ¶
type AuthWebhookRequest struct { Token string `json:"token"` Method Method `json:"method"` Attributes []AccessAttribute `json:"attributes"` }
AuthWebhookRequest represents the request of authentication webhook.
func NewAuthWebhookRequest ¶
func NewAuthWebhookRequest(reader io.Reader) (*AuthWebhookRequest, error)
NewAuthWebhookRequest creates a new instance of AuthWebhookRequest.
type AuthWebhookResponse ¶
AuthWebhookResponse represents the response of authentication webhook.
func NewAuthWebhookResponse ¶
func NewAuthWebhookResponse(reader io.Reader) (*AuthWebhookResponse, error)
NewAuthWebhookResponse creates a new instance of AuthWebhookResponse.
type ChangeSummary ¶
type ChangeSummary struct { // ID is the unique identifier of the change. ID change.ID // Message is the message of the change. Message string // Snapshot is the snapshot of the document. Snapshot string }
ChangeSummary represents a summary of change.
type Client ¶
type Client struct { ID *time.ActorID PresenceInfo PresenceInfo }
Client represents the Client that communicates with the Server.
type DocEventType ¶
type DocEventType string
DocEventType represents the event that the Server delivers to the client.
const ( // DocumentsChangedEvent is an event indicating that documents are being // modified by a change. DocumentsChangedEvent DocEventType = "documents-changed" // DocumentsWatchedEvent is an event that occurs when documents are watched // by other clients. DocumentsWatchedEvent DocEventType = "documents-watched" // DocumentsUnwatchedEvent is an event that occurs when documents are // unwatched by other clients. DocumentsUnwatchedEvent DocEventType = "documents-unwatched" // PresenceChangedEvent is an event indicating that presence is changed. PresenceChangedEvent DocEventType = "presence-changed" )
type DocumentSummary ¶
type DocumentSummary struct { // ID is the unique identifier of the change. ID ID // Key is the key of the document. Key key.Key // CreatedAt is the time when the document is created. CreatedAt time.Time // AccessedAt is the time when the document is accessed. AccessedAt time.Time // UpdatedAt is the time when the document is updated. UpdatedAt time.Time // Snapshot is the string representation of the document. Snapshot string }
DocumentSummary represents a summary of change.
type ID ¶
type ID string
ID represents ID of entity.
func IDFromActorID ¶
IDFromActorID returns ID represented by the encoded hexadecimal string from actor ID.
func IDFromBytes ¶
IDFromBytes returns ID represented by the encoded hexadecimal string from bytes.
type Method ¶
type Method string
Method represents a method name of RPC.
const ( ActivateClient Method = "ActivateClient" DeactivateClient Method = "DeactivateClient" AttachDocument Method = "AttachDocument" DetachDocument Method = "DetachDocument" PushPull Method = "PushPull" WatchDocuments Method = "WatchDocuments" ListChanges Method = "ListChangeSummaries" )
Belows are the names of RPCs.
func AuthMethods ¶
func AuthMethods() []Method
AuthMethods returns a slice of methods that can be used for authorization.
type PresenceInfo ¶
PresenceInfo is a presence information with logical clock.
func (*PresenceInfo) Update ¶
func (i *PresenceInfo) Update(info PresenceInfo) bool
Update updates the given presence information with the given clock.
type Project ¶
type Project struct { // ID is the unique ID of the project. ID ID `json:"id"` // Name is the name of this project. Name string `json:"name"` // PublicKey is the API key of this project. PublicKey string `json:"public_key"` // SecretKey is the secret key of this project. SecretKey string `json:"secret_key"` // AuthWebhookURL is the url of the authorization webhook. AuthWebhookURL string `json:"auth_webhook_url"` // AuthWebhookMethods is the methods that run the authorization webhook. AuthWebhookMethods []string `json:"auth_webhook_methods"` // CreatedAt is the time when the project was created. CreatedAt time.Time `json:"created_at"` }
Project is a project that consists of multiple documents and clients. It allows developers to work on the same cluster.
func (*Project) RequireAuth ¶
RequireAuth returns whether the given method requires authorization.