gophish: github.com/gophish/gophish/controllers/api Index | Files

package api

import "github.com/gophish/gophish/controllers/api"

Index

Package Files

campaign.go group.go imap.go import.go page.go reset.go response.go server.go smtp.go template.go user.go util.go webhook.go

Variables

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

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

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

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

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.

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

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

func JSONResponse Uses

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.

type Server Uses

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 Uses

func NewServer(options ...ServerOption) *Server

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

func (*Server) Campaign Uses

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 Uses

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 Uses

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 Uses

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

CampaignSummary returns the summary for a given campaign.

func (*Server) Campaigns Uses

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 Uses

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

CampaignsSummary returns the summary for the current user's campaigns

func (*Server) Group Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

IMAPServer handles requests for the /api/imapserver/ endpoint

func (*Server) IMAPServerValidate Uses

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

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

func (*Server) ImportEmail Uses

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

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

func (*Server) ImportGroup Uses

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

ImportGroup imports a CSV of group members

func (*Server) ImportSite Uses

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 Uses

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 Uses

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

Pages handles requests for the /api/pages/ endpoint

func (*Server) Reset Uses

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

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

func (*Server) SendTestEmail Uses

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 Uses

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 Uses

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

SendingProfiles handles requests for the /api/smtp/ endpoint

func (*Server) ServeHTTP Uses

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

func (*Server) Template Uses

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

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

func (*Server) Templates Uses

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

Templates handles the functionality for the /api/templates endpoint

func (*Server) User Uses

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 Uses

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 Uses

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 Uses

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

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

func (*Server) Webhooks Uses

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

Webhooks returns a list of webhooks, both active and disabled

type ServerOption Uses

type ServerOption func(*Server)

ServerOption is an option to apply to the API server.

func WithLimiter Uses

func WithLimiter(limiter *ratelimit.PostLimiter) ServerOption

func WithWorker Uses

func WithWorker(w worker.Worker) ServerOption

WithWorker is an option that sets the background worker.

Package api imports 25 packages (graph) and is imported by 2 packages. Updated 2020-12-09. Refresh now. Tools for package owners.