api

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 28 Imported by: ? 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

Index

Constants

This section is empty.

Variables

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 ErrEmptyTeam = errors.New("no team specified")

ErrEmptyTeam is thrown when no team 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 ContentPack added in v0.18.0

type ContentPack struct {
	FormatVersion string            `json:"format_version"`
	Name          string            `json:"name,omitempty"`
	Templates     []models.Template `json:"templates"`
	Pages         []models.Page     `json:"pages"`
}

ContentPack is the export/import bundle format for sharing Templates and Pages between Gophish instances. Templates and Pages serialize cleanly via their own json tags (UserId/TeamId are already `json:"-"`).

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) CampaignReport added in v0.18.0

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

CampaignReport (/api/campaigns/{id}/report) returns the aggregated, PII-free report for a campaign: funnel counts, rates, timing, and the engagement timeline. It is produced identically for normal and anonymized campaigns.

func (*Server) CampaignResendFailed

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

CampaignResendFailed resends every result within a campaign that's currently in an Error status

func (*Server) CampaignResultReport

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

CampaignResultReport marks a single result within a campaign as reported. This lets an admin flag a result as reported from the admin UI itself, rather than the browser calling the phishing server's /report endpoint directly - that endpoint is often on a different origin/scheme than the admin panel (e.g. plain HTTP vs. the admin panel's HTTPS), which browsers block as mixed content.

func (*Server) CampaignResultResend

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

CampaignResultResend resends a single result within a campaign that previously failed to send. Only valid for results currently in an Error status

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) CampaignScrub added in v0.18.0

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

CampaignScrub (/api/campaigns/{id}/scrub) permanently removes the recipient-identifying data from a campaign's results and events, anonymizing it while preserving the aggregate reporting data. This is irreversible.

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) ContentPackExport added in v0.18.0

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

ContentPackExport bundles the requested Templates and Pages (scoped to the caller's team) into a single Content Pack document.

func (*Server) ContentPackImport added in v0.18.0

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

ContentPackImport creates a new Template/Page for every entry in the uploaded Content Pack, scoped to the caller's team. Name collisions are resolved by appending a numbered suffix rather than failing the import, and a failure on one item doesn't abort the rest.

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) IMAPServer

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

IMAPServer handles requests for the /api/imapserver/ endpoint

func (*Server) IMAPServerValidate

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

IMAPServerValidate handles requests for the /api/imapserver/validate endpoint

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) Tag added in v0.18.0

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

Tag handles the functionality for the /api/tags/:id endpoint

func (*Server) Tags added in v0.18.0

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

Tags handles the functionality for the /api/tags/ endpoint

func (*Server) Teams

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

Teams handles requests for the /api/teams/ endpoint. Team management is admin-only (see the PermissionModifySystem guard in server.go) the same team assignment happens through the Users endpoints for everyone else

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.

func (*Server) ValidateWebhook

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

ValidateWebhook makes an HTTP request to a specified remote url to ensure that it's valid.

func (*Server) Webhook

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

Webhook returns details of a single webhook specified by "id" parameter

func (*Server) Webhooks

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

Webhooks returns a list of webhooks, both active and disabled

type ServerOption

type ServerOption func(*Server)

ServerOption is an option to apply to the API server.

func WithLimiter

func WithLimiter(limiter *ratelimit.PostLimiter) ServerOption

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