controllers

package
v0.0.0-...-bfc522d Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package controllers is responsible for setting up the routing and controllers (http.Handlers) for go-gomailtrike.

Index

Constants

View Source
const TransparencySuffix = "+"

Variables

View Source
var ErrCampaignComplete = errors.New("Event received on completed campaign")

ErrCampaignComplete is thrown when an event is received for a campaign that has already been marked as complete.

View Source
var ErrInvalidRequest = errors.New("Invalid request")

ErrInvalidRequest is thrown when a request with an invalid structure is received

Functions

func Flash

func Flash(w http.ResponseWriter, r *http.Request, t string, m string)

Flash handles the rendering flash messages

Types

type AdminServer

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

AdminServer is an HTTP server that implements the administrative trust_strike handlers, including the dashboard and REST API.

func NewAdminServer

func NewAdminServer(config config.AdminServer, keycloak config.Keycloak, options ...AdminServerOption) *AdminServer

NewAdminServer returns a new instance of the AdminServer with the provided config and options applied.

func (*AdminServer) Base

func (as *AdminServer) Base(w http.ResponseWriter, r *http.Request)

Base handles the default path and template execution

func (*AdminServer) CampaignEdit

func (as *AdminServer) CampaignEdit(w http.ResponseWriter, r *http.Request)

CampaignEdit handles the editing and creation of campaigns on a dedicated page

func (*AdminServer) CampaignID

func (as *AdminServer) CampaignID(w http.ResponseWriter, r *http.Request)

CampaignID handles the default path and template execution

func (*AdminServer) Campaigns

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

Campaigns handles the default path and template execution

func (*AdminServer) DNSConfig

func (as *AdminServer) DNSConfig(w http.ResponseWriter, r *http.Request)

DNSConfig handles the DNS Configuration page

func (*AdminServer) EmailSendingProfiles

func (as *AdminServer) EmailSendingProfiles(w http.ResponseWriter, r *http.Request)

EmailSendingProfiles handles the default path and template execution

func (*AdminServer) EmailTemplates

func (as *AdminServer) EmailTemplates(w http.ResponseWriter, r *http.Request)

EmailTemplates handles the default path and template execution

func (*AdminServer) GroupEdit

func (as *AdminServer) GroupEdit(w http.ResponseWriter, r *http.Request)

GroupEdit handles the editing and creation of groups on a dedicated page

func (*AdminServer) Groups

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

Groups handles the default path and template execution

func (*AdminServer) Impersonate

func (as *AdminServer) Impersonate(w http.ResponseWriter, r *http.Request)

Impersonate allows an admin to login to a user account without needing the password

func (*AdminServer) KeycloakCallback

func (as *AdminServer) KeycloakCallback(w http.ResponseWriter, r *http.Request)

func (*AdminServer) KeycloakLogin

func (as *AdminServer) KeycloakLogin(w http.ResponseWriter, r *http.Request)

func (*AdminServer) LandingPageEdit

func (as *AdminServer) LandingPageEdit(w http.ResponseWriter, r *http.Request)

LandingPageEdit handles the editing and creation of landing pages on a dedicated page

func (*AdminServer) LandingPages

func (as *AdminServer) LandingPages(w http.ResponseWriter, r *http.Request)

LandingPages handles the default path and template execution

func (*AdminServer) Login

func (as *AdminServer) Login(w http.ResponseWriter, r *http.Request)

Login handles the authentication flow for a user. If credentials are valid, a session is created

func (*AdminServer) LoginPages

func (as *AdminServer) LoginPages(w http.ResponseWriter, r *http.Request)

LoginPages handles the default path and template execution

func (*AdminServer) Logout

func (as *AdminServer) Logout(w http.ResponseWriter, r *http.Request)

Logout destroys the current user session

func (*AdminServer) Phishlets

func (as *AdminServer) Phishlets(w http.ResponseWriter, r *http.Request)

Phishlets handles the phishlet management page

func (*AdminServer) QRCampaigns

func (as *AdminServer) QRCampaigns(w http.ResponseWriter, r *http.Request)

QRCampaigns handles the default path and template execution

func (*AdminServer) QRTemplates

func (as *AdminServer) QRTemplates(w http.ResponseWriter, r *http.Request)

QRTemplates handles the default path and template execution

func (*AdminServer) Redirectors

func (as *AdminServer) Redirectors(w http.ResponseWriter, r *http.Request)

Redirectors handles the redirectors management page

func (*AdminServer) ResetPassword

func (as *AdminServer) ResetPassword(w http.ResponseWriter, r *http.Request)

ResetPassword handles the password reset flow when a password change is required either by the trust_strike system or an administrator.

This handler is meant to be used when a user is required to reset their password, not just when they want to.

This is an important distinction since in this handler we don't require the user to re-enter their current password, as opposed to the flow through the settings handler.

To that end, if the user doesn't require a password change, we will redirect them to the settings page.

func (*AdminServer) SMSCampaigns

func (as *AdminServer) SMSCampaigns(w http.ResponseWriter, r *http.Request)

SMSCampaigns handles the default path and template execution

func (*AdminServer) SMSSendingProfiles

func (as *AdminServer) SMSSendingProfiles(w http.ResponseWriter, r *http.Request)

SMSSendingProfiles handles the default path and template execution

func (*AdminServer) SMSTemplates

func (as *AdminServer) SMSTemplates(w http.ResponseWriter, r *http.Request)

SMSTemplates handles the default path and template execution

func (*AdminServer) SendingProfileEdit

func (as *AdminServer) SendingProfileEdit(w http.ResponseWriter, r *http.Request)

SendingProfileEdit handles the editing and creation of sending profiles on a dedicated page

func (*AdminServer) SendingProfiles

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

SendingProfiles handles the default path and template execution

func (*AdminServer) Settings

func (as *AdminServer) Settings(w http.ResponseWriter, r *http.Request)

Settings handles the changing of settings

func (*AdminServer) Shutdown

func (as *AdminServer) Shutdown() error

Shutdown attempts to gracefully shutdown the server.

func (*AdminServer) Start

func (as *AdminServer) Start()

Start launches the admin server, listening on the configured address.

func (*AdminServer) StartEC2Scheduler

func (as *AdminServer) StartEC2Scheduler()

StartEC2Scheduler starts the background EC2 auto-shutdown scheduler

func (*AdminServer) StopImpersonating

func (as *AdminServer) StopImpersonating(w http.ResponseWriter, r *http.Request)

StopImpersonating stops the impersonation session and reverts to the original user

func (*AdminServer) TemplateEdit

func (as *AdminServer) TemplateEdit(w http.ResponseWriter, r *http.Request)

TemplateEdit handles the editing and creation of templates on a dedicated page

func (*AdminServer) Templates

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

Templates handles the default path and template execution

func (*AdminServer) UserManagement

func (as *AdminServer) UserManagement(w http.ResponseWriter, r *http.Request)

UserManagement is an admin-only handler that allows for the registration and management of user accounts within trust_strike.

func (*AdminServer) Webhooks

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

Webhooks is an admin-only handler that handles webhooks

type AdminServerOption

type AdminServerOption func(*AdminServer)

AdminServerOption is a functional option that is used to configure the admin server

func WithGlobalConfig

func WithGlobalConfig(cfg *config.Config) AdminServerOption

func WithWorker

func WithWorker(w worker.Worker) AdminServerOption

WithWorker is an option that sets the background worker.

type PhishingServer

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

PhishingServer is an HTTP server that implements the campaign event handlers, such as email open tracking, click tracking, and more.

func NewPhishingServer

func NewPhishingServer(config config.PhishServer, options ...PhishingServerOption) *PhishingServer

NewPhishingServer returns a new instance of the phishing server with provided options applied.

func (*PhishingServer) PhishHandler

func (ps *PhishingServer) PhishHandler(w http.ResponseWriter, r *http.Request)

PhishHandler handles incoming client connections and registers the associated actions performed (such as clicked link, etc.)

func (*PhishingServer) ReportHandler

func (ps *PhishingServer) ReportHandler(w http.ResponseWriter, r *http.Request)

ReportHandler tracks emails as they are reported, updating the status for the given Result

func (*PhishingServer) RobotsHandler

func (ps *PhishingServer) RobotsHandler(w http.ResponseWriter, r *http.Request)

RobotsHandler prevents search engines, etc. from indexing phishing materials

func (*PhishingServer) Shutdown

func (ps *PhishingServer) Shutdown() error

Shutdown attempts to gracefully shutdown the server.

func (*PhishingServer) Start

func (ps *PhishingServer) Start()

Start launches the phishing server, listening on the configured address.

func (*PhishingServer) TrackHandler

func (ps *PhishingServer) TrackHandler(w http.ResponseWriter, r *http.Request)

TrackHandler tracks emails as they are opened, updating the status for the given Result

func (*PhishingServer) TransparencyHandler

func (ps *PhishingServer) TransparencyHandler(w http.ResponseWriter, r *http.Request)

TransparencyHandler returns a TransparencyResponse for the provided result and campaign.

type PhishingServerOption

type PhishingServerOption func(*PhishingServer)

PhishingServerOption is a functional option that is used to configure the the phishing server

func WithContactAddress

func WithContactAddress(addr string) PhishingServerOption

WithContactAddress sets the contact address used by the transparency handlers

type TransparencyResponse

type TransparencyResponse struct {
	Server         string    `json:"server"`
	ContactAddress string    `json:"contact_address"`
	SendDate       time.Time `json:"send_date"`
}

TransparencyResponse is the JSON response provided when a third-party makes a request to the transparency handler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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