api

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyPassword = errors.New("No password provided")

ErrEmptyPassword is thrown when a user provides a blank password to the register or change password functions

View Source
var ErrEmptyRole = errors.New("No role specified")

ErrEmptyRole is throws when no role is provided when creating or modifying a user.

View Source
var ErrEmptyUsername = errors.New("No username provided")

ErrEmptyUsername is thrown when a user attempts to register a username that is taken.

View Source
var ErrInsufficientPermission = errors.New("Permission denied")

ErrInsufficientPermission is thrown when a user attempts to change an attribute (such as the role) for which they don't have permission.

View Source
var ErrUsernameTaken = errors.New("Username already taken")

ErrUsernameTaken is thrown when a user attempts to register a username that is taken.

Functions

func JSONResponse

func JSONResponse(w http.ResponseWriter, d interface{}, c int)

JSONResponse attempts to set the status code, c, and marshal the given interface, d, into a response that is written to the given ResponseWriter.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents the routes and functionality of the Gophish API. It's not a server in the traditional sense, in that it isn't started and stopped. Rather, it's meant to be used as an http.Handler in the AdminServer.

func NewServer

func NewServer(options ...ServerOption) *Server

NewServer returns a new instance of the API handler with the provided options applied.

func (*Server) Campaign

func (as *Server) Campaign(w http.ResponseWriter, r *http.Request)

Campaign returns details about the requested campaign. If the campaign is not valid, APICampaign returns null.

func (*Server) CampaignComplete

func (as *Server) CampaignComplete(w http.ResponseWriter, r *http.Request)

CampaignComplete effectively "ends" a campaign. Future phishing emails clicked will return a simple "404" page.

func (*Server) CampaignResults

func (as *Server) CampaignResults(w http.ResponseWriter, r *http.Request)

CampaignResults returns just the results for a given campaign to significantly reduce the information returned.

func (*Server) CampaignSummary

func (as *Server) CampaignSummary(w http.ResponseWriter, r *http.Request)

CampaignSummary returns the summary for a given campaign.

func (*Server) Campaigns

func (as *Server) Campaigns(w http.ResponseWriter, r *http.Request)

Campaigns returns a list of campaigns if requested via GET. If requested via POST, APICampaigns creates a new campaign and returns a reference to it.

func (*Server) CampaignsSummary

func (as *Server) CampaignsSummary(w http.ResponseWriter, r *http.Request)

CampaignsSummary returns the summary for the current user's campaigns

func (*Server) Group

func (as *Server) Group(w http.ResponseWriter, r *http.Request)

Group returns details about the requested group. If the group is not valid, Group returns null.

func (*Server) GroupSummary

func (as *Server) GroupSummary(w http.ResponseWriter, r *http.Request)

GroupSummary returns a summary of the groups owned by the current user.

func (*Server) Groups

func (as *Server) Groups(w http.ResponseWriter, r *http.Request)

Groups returns a list of groups if requested via GET. If requested via POST, APIGroups creates a new group and returns a reference to it.

func (*Server) GroupsSummary

func (as *Server) GroupsSummary(w http.ResponseWriter, r *http.Request)

GroupsSummary returns a summary of the groups owned by the current user.

func (*Server) ImportEmail

func (as *Server) ImportEmail(w http.ResponseWriter, r *http.Request)

ImportEmail allows for the importing of email. Returns a Message object

func (*Server) ImportGroup

func (as *Server) ImportGroup(w http.ResponseWriter, r *http.Request)

ImportGroup imports a CSV of group members

func (*Server) ImportSite

func (as *Server) ImportSite(w http.ResponseWriter, r *http.Request)

ImportSite allows for the importing of HTML from a website Without "include_resources" set, it will merely place a "base" tag so that all resources can be loaded relative to the given URL.

func (*Server) Page

func (as *Server) Page(w http.ResponseWriter, r *http.Request)

Page contains functions to handle the GET'ing, DELETE'ing, and PUT'ing of a Page object

func (*Server) Pages

func (as *Server) Pages(w http.ResponseWriter, r *http.Request)

Pages handles requests for the /api/pages/ endpoint

func (*Server) Reset

func (as *Server) Reset(w http.ResponseWriter, r *http.Request)

Reset (/api/reset) resets the currently authenticated user's API key

func (*Server) SendTestEmail

func (as *Server) SendTestEmail(w http.ResponseWriter, r *http.Request)

SendTestEmail sends a test email using the template name and Target given.

func (*Server) SendingProfile

func (as *Server) SendingProfile(w http.ResponseWriter, r *http.Request)

SendingProfile contains functions to handle the GET'ing, DELETE'ing, and PUT'ing of a SMTP object

func (*Server) SendingProfiles

func (as *Server) SendingProfiles(w http.ResponseWriter, r *http.Request)

SendingProfiles handles requests for the /api/smtp/ endpoint

func (*Server) ServeHTTP

func (as *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Template

func (as *Server) Template(w http.ResponseWriter, r *http.Request)

Template handles the functions for the /api/templates/:id endpoint

func (*Server) Templates

func (as *Server) Templates(w http.ResponseWriter, r *http.Request)

Templates handles the functionality for the /api/templates endpoint

func (*Server) User

func (as *Server) User(w http.ResponseWriter, r *http.Request)

User contains functions to retrieve or delete a single user. Users with the ModifySystem permission can view and modify any user. Otherwise, users may only view or delete their own account.

func (*Server) Users

func (as *Server) Users(w http.ResponseWriter, r *http.Request)

Users contains functions to retrieve a list of existing users or create a new user. Users with the ModifySystem permissions can view and create users.

type ServerOption

type ServerOption func(*Server)

ServerOption is an option to apply to the API server.

func WithWorker

func WithWorker(w worker.Worker) ServerOption

WithWorker is an option that sets the background worker.

Jump to

Keyboard shortcuts

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