api

package
v0.0.0-...-18cdda1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(uints []uint, i uint) bool

func GetErrorFromHtml

func GetErrorFromHtml(res http.Response) (*string, error)

GetErrorFromHtml - retrieve error text from CTFd HTML

Types

type ApiResponse

type ApiResponse struct {
	Meta    *Meta            `json:"meta"`
	Success bool             `json:"success"`
	Message string           `json:"message"`
	Data    *json.RawMessage `json:"data"`
}

ApiResponse -

type AuthStruct

type AuthStruct struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Nonce    string `json:"nonce"`
	Token    string `json:"token"`
}

AuthStruct -

type Client

type Client struct {
	HostUrl    string
	HttpClient *http.Client
	Auth       AuthStruct
	UserAgent  string
}

Client -

func NewClient

func NewClient(host, username, password *string, userAgent *string) (*Client, error)

NewClient -

func (*Client) CheckSetup

func (client *Client) CheckSetup() error

CheckSetup - verify that a CTFd instance has been setup

func (*Client) CreateCtfdSetup

func (client *Client) CreateCtfdSetup(setup CtfdSetup) error

CreateCtfdSetup - setup a new CTFd instance

func (*Client) CreateTeam

func (client *Client) CreateTeam(team NewTeam) (*Team, error)

CreateTeam - create a new team

func (*Client) CreateToken

func (client *Client) CreateToken() (newToken *Token, err error)

CreateToken - create a token object

func (*Client) CreateUser

func (client *Client) CreateUser(user NewUser) (*User, error)

CreateUser - create a new user

func (*Client) CreateUserTeamMembership

func (client *Client) CreateUserTeamMembership(teamId uint, userId uint) (*UserTeamMembership, error)

CreateUserTeamMembership - create a new userTeamMembership

func (*Client) DeleteCtfdSetup

func (client *Client) DeleteCtfdSetup() error

DeleteCtfdSetup - remove CTFd setup

func (*Client) DeleteTeam

func (client *Client) DeleteTeam(id uint) error

DeleteTeam - remove an existing team

func (*Client) DeleteUser

func (client *Client) DeleteUser(id uint) error

DeleteUser - remove an existing user

func (*Client) DeleteUserTeamMembership

func (client *Client) DeleteUserTeamMembership(teamId uint, userId uint) error

DeleteUserTeamMembership - remove an existing userTeamMembership

func (*Client) DoApiRequest

func (client *Client) DoApiRequest(req *http.Request) (*json.RawMessage, error)

func (*Client) DoRequest

func (client *Client) DoRequest(req *http.Request) (io.ReadCloser, error)

func (*Client) GetChallenges

func (client *Client) GetChallenges() (interface{}, error)

GetChallenges - Returns list of challenges

func (*Client) GetCtfdSetup

func (client *Client) GetCtfdSetup() (*CtfdSetup, error)

GetCtfdSetup - Retrieve details of the CTFd setup

func (*Client) GetOrCreateToken

func (client *Client) GetOrCreateToken() (*Token, error)

GetOrCreateToken - re-use or create a token object

func (*Client) GetTeam

func (client *Client) GetTeam(id uint) (*Team, error)

GetTeam - Returns details of a team

func (*Client) GetTeamMemberships

func (client *Client) GetTeamMemberships(id uint) (*[]uint, error)

GetTeamMemberships - Returns memberships of a team

func (*Client) GetTeams

func (client *Client) GetTeams() (interface{}, error)

GetTeams - Returns list of teams

func (*Client) GetTokens

func (client *Client) GetTokens() (*[]Token, error)

GetTokens - get token objects in bulk

func (*Client) GetUser

func (client *Client) GetUser(id uint) (*User, error)

GetUser - Returns details of a user

func (*Client) GetUsers

func (client *Client) GetUsers() (interface{}, error)

GetUsers - Returns list of users

func (*Client) SignIn

func (client *Client) SignIn() error

SignIn - Authenticate the Admin. user

func (*Client) SignOut

func (client *Client) SignOut() error

SignOut - Request the logout page

func (*Client) UpdateTeam

func (client *Client) UpdateTeam(id uint, team NewTeam) (*Team, error)

UpdateTeam - updated an existing team

func (*Client) UpdateUser

func (client *Client) UpdateUser(id uint, user NewUser) (*User, error)

UpdateUser - updated an existing user

type CtfdSetup

type CtfdSetup struct {
	Name              string       `json:"name"`
	Description       string       `json:"description"`
	AdminEmail        string       `json:"admin_email"`
	ConfigurationPath string       `json:"configuration_path"`
	Email             *EmailConfig `json:"email"`
}

CtfdSetup - `ctfd_setup` resource

type EmailConfig

type EmailConfig struct {
	Username    string `json:"mail_username"`
	Password    string `json:"mail_password"`
	FromAddress string `json:"mailfrom_addr"`
	Server      string `json:"mail_server"`
	Port        int    `json:"mail_port"`
	UseAuth     bool   `json:"mail_useauth"`
	UseTls      bool   `json:"mail_tls"`
	UseSsl      bool   `json:"mail_ssl"`
}

type Meta

type Meta struct {
	Pagination Pagination `json:"pagination"`
}

Meta -

type NewTeam

type NewTeam struct {
	Name        string `json:"name"`
	Email       string `json:"email"`
	Password    string `json:"password"`
	Website     string `json:"website"`
	Affiliation string `json:"affiliation"`
	Country     string `json:"country"`
	Hidden      bool   `json:"hidden"`
	Banned      bool   `json:"banned"`
}

type NewUser

type NewUser struct {
	Name        string `json:"name"`
	Email       string `json:"email"`
	Password    string `json:"password"`
	Website     string `json:"website"`
	Affiliation string `json:"affiliation"`
	Country     string `json:"country"`
	Hidden      bool   `json:"hidden"`
	Banned      bool   `json:"banned"`
	Type        string `json:"type"`
	Verified    bool   `json:"verified"`
}

NewUser - fields required when creating a new user

type Pagination

type Pagination struct {
	Page    uint  `json:"page"`
	Next    *uint `json:"next"`
	Prev    *uint `json:"prev"`
	Pages   uint  `json:"pages"`
	PerPage uint  `json:"per_page"`
	Total   uint  `json:"total"`
}

Pagination -

type Team

type Team struct {
	Name        string   `json:"name"`
	Email       string   `json:"email"`
	Password    string   `json:"password"`
	Website     string   `json:"website"`
	Affiliation string   `json:"affiliation"`
	Country     string   `json:"country"`
	Hidden      bool     `json:"hidden"`
	Banned      bool     `json:"banned"`
	CaptainId   *uint    `json:"captain_id"`
	Bracket     string   `json:"bracket"`
	Id          uint     `json:"id"`
	Secret      string   `json:"secret"`
	OauthId     string   `json:"oauth_id"`
	Members     []uint   `json:"members"`
	Created     string   `json:"created"`
	Fields      []string `json:"fields"`
}

type Token

type Token struct {
	Id         uint   `json:"id"`
	Type       string `json:"type"`
	UserId     uint   `json:"user_id"`
	Created    string `json:"created"`
	Expiration string `json:"expiration"`
	Value      string `json:"value"`
}

type User

type User struct {
	Id          uint     `json:"id"`
	Name        string   `json:"name"`
	Email       string   `json:"email"`
	Password    string   `json:"password"`
	Website     string   `json:"website"`
	Affiliation string   `json:"affiliation"`
	Country     string   `json:"country"`
	Bracket     string   `json:"bracket"`
	Secret      string   `json:"secret"`
	OauthId     string   `json:"oauth_id"`
	Fields      []string `json:"fields"`
	Type        string   `json:"type"`
	TeamId      uint     `json:"team_id"`
	Verified    bool     `json:"verified"`
	Hidden      bool     `json:"hidden"`
	Banned      bool     `json:"banned"`
}

User - fields as returned from the CTFd API

type UserTeamMembership

type UserTeamMembership struct {
	UserId uint `json:"user_id"`
	TeamId uint `json:"team_id"`
}

UserTeamMembership - fields as returned from the CTFd API

Jump to

Keyboard shortcuts

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