Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { GetHealth() (string, error) GetAliases() ([]Alias, error) GetAlias(id string) (Alias, error) GetAliasByID(id string) (Alias, error) GetAliasByPayloadID(id string) (Alias, error) AddAlias(name string, payloadID string) (Alias, error) DeleteAlias(id string) error GetLoots() ([]Loot, error) GetLoot(id string) (Loot, error) AddLoot(data string) (Loot, error) DeleteLoot(id string) error GetExecutions() ([]Execution, error) GetExecution(id string) (Execution, error) AddExecution(payloadID string, aliasID string) (Execution, error) DeleteExecution(id string) error GetInjections() ([]Injection, error) GetInjection(id string) (Injection, error) AddInjection(name string, content string) (Injection, error) DeleteInjection(id string) error GetPayloads() ([]Payload, error) GetPayload(id string) (Payload, error) AddPayload(name string, content string, contentType string) (Payload, error) DeletePayload(id string) error //Login doesn't return a user but a JWT token if the auth is successful Login(loginParam, passwordParam, otp string) (string, error) GetUserByName(name string) (User, error) GetUser(id string) (User, error) CreateOTP(userID string, secret string, otp string) (User, error) CreateUser(username, password string) (User, error) DeleteUser(id string) error }
API is the general API interface used by all the API. All field must be implemented to be able to create a new "api" For example, the Local and HTTP APIs are using the same interface so we can call them with the same calling convention
type Alias ¶
type Alias struct { ID string `json:"id" mapstructure:"id"` PayloadID string `json:"payload_id" mapstructure:"payload_id"` // Used for SRI (sub ressource integrity) Alias string `json:"alias" mapstructure:"alias"` // Used for SRI (sub ressource integrity) CreatedAt time.Time `json:"created_at" mapstructure:"created_at"` ModifiedAt time.Time `json:"modified_at" mapstructure:"modified_at"` }
Alias represent the structure of the frontend-facing Aliases. Not the stored one. It offers an `FromStorage` function to convert itself from the storage payload.
type Error ¶
type Error int
Error defines all the errors that can be sent by the API.
type Execution ¶
type Execution struct { ID string `json:"id" mapstructure:"id"` PayloadID string `json:"payload_id" mapstructure:"payload_id"` AliasID string `json:"alias_id" mapstructure:"alias_id"` TriggeredAt time.Time `json:"triggered_at" mapstructure:"triggered_at"` }
Execution represent the structure of the frontend-facing Executions. Not the stored one. It offers an `FromStorage` function to convert itself from the storage payload.
type Injection ¶
type Injection struct { ID string `json:"id" mapstructure:"id"` Name string `json:"name" mapstructure:"name"` Content string `json:"content" mapstructure:"content"` CreatedAt time.Time `json:"created_at" mapstructure:"created_at"` ModifiedAt time.Time `json:"modified_at" mapstructure:"modified_at"` }
Injection represent the structure of the frontend-facing Executions. Not the stored one. It offers an `FromStorage` function to convert itself from the storage payload.
type Loot ¶
type Loot struct { ID string `json:"id" mapstructure:"id"` Data string `json:"data" mapstructure:"data"` CreatedAt time.Time `json:"created_at" mapstructure:"created_at"` }
Loot represent the structure of the frontend-facing Executions. Not the stored one. It offers an `FromStorage` function to convert itself from the storage payload.
type Payload ¶
type Payload struct { ID string `json:"id" mapstructure:"id"` Name string `json:"name" mapstructure:"name"` Content string `json:"content" mapstructure:"content"` ContentType string `json:"content_type" mapstructure:"content_type"` Hashes models.SRIHashes `json:"hashes" mapstructure:"hashes"` // Used for SRI (sub ressource integrity) CreatedAt time.Time `json:"created_at" mapstructure:"created_at"` ModifiedAt time.Time `json:"modified_at" mapstructure:"modified_at"` }
Payload represent the structure of the frontend-facing payload. Not the stored one. It offers an `FromStorage` function to convert itself from the storage payload.
type Response ¶
type Response struct { Error string `json:"error,omitempty"` Data interface{} `json:"data,omitempty"` }
Response represent the main structure for ALL the response from the API The error must be empty if there wasn't an error They should also be only using the api.Error model Data can be anything but we try to not nest to many things
type User ¶
type User struct { ID string `json:"id" mapstructure:"id"` // The username is the login of the user. Username string `json:"username" mapstructure:"username"` // Is 2FA enabled on this account. // It will be used to determine if it requires another step during the login process TwoFactorEnabled bool `json:"two_factor_enabled" mapstructure:"two_factor_enabled"` CreatedAt time.Time `json:"created_at" mapstructure:"created_at"` ModifiedAt time.Time `json:"modified_at" mapstructure:"modified_at"` }
User represent the structure of the frontend-facing user. Not the stored one. It offers an `FromStorage` function to convert itself from the storage payload.