page

package
v0.1868.126 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package page provides middleware and handlers for root-level pages.

Index

Constants

View Source
const (
	PathAttorneyConfirmDontWantToBeAttorneyLoggedOut                       = Path("/confirm-you-do-not-want-to-be-an-attorney")
	PathAttorneyEnterAccessCode                                            = Path("/attorney-enter-access-code")
	PathAttorneyEnterAccessCodeOptOut                                      = Path("/attorney-enter-access-code-opt-out")
	PathAttorneyLogin                                                      = Path("/attorney-login")
	PathAttorneyLoginCallback                                              = Path("/attorney-login-callback")
	PathAttorneyStart                                                      = Path("/attorney-start")
	PathAttorneyYouHaveDecidedNotToBeAttorney                              = Path("/you-have-decided-not-to-be-an-attorney")
	PathCertificateProviderConfirmDontWantToBeCertificateProviderLoggedOut = Path("/confirm-you-do-not-want-to-be-a-certificate-provider")
	PathCertificateProviderEnterAccessCode                                 = Path("/certificate-provider-enter-access-code")
	PathCertificateProviderEnterAccessCodeOptOut                           = Path("/certificate-provider-enter-access-code-opt-out")
	PathCertificateProviderLogin                                           = Path("/certificate-provider-login")
	PathCertificateProviderLoginCallback                                   = Path("/certificate-provider-login-callback")
	PathCertificateProviderYouHaveAlreadyProvidedACertificate              = Path("/you-have-already-provided-a-certificate")
	PathCertificateProviderYouHaveAlreadyProvidedACertificateLoggedIn      = Path("/you-have-already-provided-a-certificate-logged-in")
	PathCertificateProviderYouHaveDecidedNotToBeCertificateProvider        = Path("/you-have-decided-not-to-be-a-certificate-provider")
	PathHealthCheckDependency                                              = Path("/health-check/dependency")
	PathHealthCheckService                                                 = Path("/health-check/service")
	PathSupporterEnterOrganisationName                                     = Path("/enter-the-name-of-your-organisation-or-company")
	PathSupporterEnterAccessCode                                           = Path("/supporter-access-code")
	PathSupporterEnterYourName                                             = Path("/enter-your-name")
	PathSupporterInviteExpired                                             = Path("/invite-expired")
	PathSupporterLogin                                                     = Path("/supporter-login")
	PathSupporterLoginCallback                                             = Path("/supporter-login-callback")
	PathSupporterOrganisationDeleted                                       = Path("/organisation-deleted")
	PathSupporterSigningInAdvice                                           = Path("/signing-in-with-govuk-one-login")
	PathSupporterStart                                                     = Path("/supporter-start")
	PathVoucherStart                                                       = Path("/voucher-start")
	PathVoucherLogin                                                       = Path("/voucher-login")
	PathVoucherLoginCallback                                               = Path("/voucher-login-callback")
	PathVoucherEnterAccessCode                                             = Path("/voucher-enter-access-code")
	PathVoucherUnableToConfirmIdentity                                     = Path("/voucher-unable-to-confirm-identity")
	PathVoucherDonorDetailsDoNotMatch                                      = Path("/voucher-donor-details-do-not-match")
	PathYouCannotVouchForDonor                                             = Path("/you-cannot-vouch-for-donor")

	PathAccessibilityStatement      = Path("/accessibility-statement")
	PathAttorneyFixtures            = Path("/fixtures/attorney")
	PathAddAnLPA                    = Path("/add-an-lpa")
	PathAuthRedirect                = Path("/auth/redirect")
	PathCertificateProviderFixtures = Path("/fixtures/certificate-provider")
	PathCertificateProviderStart    = Path("/certificate-provider-start")
	PathCookiesConsent              = Path("/cookies-consent")
	PathDashboard                   = Path("/dashboard")
	PathDashboardFixtures           = Path("/fixtures/dashboard")
	PathEnterAccessCode             = Path("/enter-access-code")
	PathFixtures                    = Path("/fixtures")
	PathLogin                       = Path("/login")
	PathLoginCallback               = Path("/login-callback")
	PathLpaDeleted                  = Path("/lpa-deleted")
	PathLpaWithdrawn                = Path("/lpa-withdrawn")
	PathMakeOrAddAnLPA              = Path("/make-or-add-an-lpa")
	PathRoot                        = Path("/")
	PathSignOut                     = Path("/sign-out")
	PathStart                       = Path("/start")
	PathSupporterFixtures           = Path("/fixtures/supporter")
	PathVoucherFixtures             = Path("/fixtures/voucher")

	PathAddingRestrictionsAndConditions          = Path("/help-and-support/adding-restrictions-and-conditions")
	PathContactTheOfficeOfThePublicGuardian      = Path("/help-and-support/contact-the-office-of-the-public-guardian")
	PathGlossary                                 = Path("/help-and-support/glossary")
	PathHowDecisionsAreMadeWithMultipleAttorneys = Path("/help-and-support/how-decisions-are-made-with-multiple-attorneys")
	PathHowToMakeAndRegisterYourLPA              = Path("/help-and-support/how-to-make-and-register-your-lasting-power-of-attorney")
	PathHowToSelectAttorneysForAnLPA             = Path("/help-and-support/how-to-select-attorneys-for-a-lasting-power-of-attorney")
	PathReplacementAttorneys                     = Path("/help-and-support/replacement-attorneys")
	PathTheTwoTypesOfLPAPath                     = Path("/help-and-support/the-two-types-of-lasting-power-of-attorney")
	PathUnderstandingLifeSustainingTreatment     = Path("/help-and-support/understanding-life-sustaining-treatment")
	PathUnderstandingMentalCapacity              = Path("/help-and-support/understanding-mental-capacity")
)
View Source
const FormUrlEncoded = "application/x-www-form-urlencoded"

Variables

View Source
var ErrCsrfInvalid = errors.New("CSRF token not valid")

Functions

func AuthRedirect

func AuthRedirect(logger Logger, sessionStore SessionStore) http.HandlerFunc

func CacheControlHeaders

func CacheControlHeaders(h http.Handler) http.Handler

func CookieConsent

func CookieConsent() http.HandlerFunc

func DependencyHealthCheck

func DependencyHealthCheck(services map[string]HealthChecker) http.HandlerFunc

func PostFormReferenceNumber

func PostFormReferenceNumber(r *http.Request, name string) string

func PostFormString

func PostFormString(r *http.Request, name string) string

func Recover

func Recover(tmpl template.Template, logger Logger, bundle Bundle, next http.Handler) http.HandlerFunc

func ValidateCsrf

func ValidateCsrf(next http.Handler, store SessionStore, randomString func(int) string, errorHandler ErrorHandler) http.HandlerFunc

Types

type AccessCodeStore added in v0.1868.36

type AccessCodeStore interface {
	Get(ctx context.Context, actorType actor.Type, code accesscodedata.Hashed) (accesscodedata.Link, error)
}

type Bundle

type Bundle interface {
	For(lang localize.Lang) localize.Localizer
}

type DashboardStore

type DashboardStore interface {
	GetAll(ctx context.Context) (results dashboarddata.Results, err error)
	SubExistsForActorType(ctx context.Context, sub string, actorType actor.Type) (bool, error)
}

type DonorStore

type DonorStore interface {
	Create(context.Context) (*donordata.Provided, error)
	Put(context.Context, *donordata.Provided) error
}

type EnterAccessCodeHandler added in v0.1868.33

type EnterAccessCodeHandler func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, session *sesh.LoginSession, lpa *lpadata.Lpa, link accesscodedata.Link) error

type ErrorHandler

type ErrorHandler func(http.ResponseWriter, *http.Request, error)

func Error

func Error(tmpl template.Template, logger Logger, showError bool) ErrorHandler

type EventClient added in v0.962.0

type EventClient interface {
	SendNotificationSent(ctx context.Context, notificationSentEvent event.NotificationSent) error
	SendPaperFormRequested(ctx context.Context, paperFormRequestedEvent event.PaperFormRequested) error
	SendMetric(ctx context.Context, category event.Category, measure event.Measure) error
}

type HandleOpt added in v0.863.0

type HandleOpt byte
const (
	None HandleOpt = 1 << iota
	RequireSession
	CanGoBack
)

type Handler

type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request) error

func AddAnLPA added in v0.1868.26

func AddAnLPA(tmpl template.Template) Handler

func Dashboard

func Dashboard(tmpl template.Template, dashboardStore DashboardStore, useURL string, sessionStore SessionStore) Handler

func EnterAccessCode added in v0.1868.33

func EnterAccessCode(tmpl template.Template, accessCodeStore AccessCodeStore, sessionStore UpdateLoginSessionStore, lpaStoreResolvingService LpaStoreResolvingService, actorType actor.Type, next EnterAccessCodeHandler) Handler

func EnterAccessCodeOptOut added in v0.1868.33

func EnterAccessCodeOptOut(tmpl template.Template, accessCodeStore AccessCodeStore, sessionStore SetLpaDataSessionStore, lpaStoreResolvingService LpaStoreResolvingService, actorType actor.Type, redirect Path) Handler

func Guidance

func Guidance(tmpl template.Template) Handler

func Login

func Login(oneLoginClient LoginOneLoginClient, sessionStore LoginSessionStore, randomString func(int) string, redirect Path) Handler

func LoginCallback

func LoginCallback(logger Logger, oneLoginClient LoginCallbackOneLoginClient, sessionStore LoginCallbackSessionStore, redirect Path, dashboardStore DashboardStore, actorType actor.Type) Handler

func MakeOrAddAnLPA added in v0.1868.26

func MakeOrAddAnLPA(tmpl template.Template, donorStore DonorStore, dashboardStore DashboardStore, eventClient EventClient) Handler

func Root

func Root(tmpl template.Template, logger Logger, donorStartURL string) Handler

func SignOut

func SignOut(logger Logger, sessionStore SessionStore, oneLoginClient OneLoginClient, donorStartURL string) Handler

type HealthChecker added in v0.805.0

type HealthChecker interface {
	CheckHealth(context.Context) error
}

type Localizer

type Localizer interface {
	localize.Localizer
}

type Logger

type Logger interface {
	InfoContext(ctx context.Context, msg string, args ...any)
	ErrorContext(ctx context.Context, msg string, args ...any)
}

type LoginCallbackOneLoginClient

type LoginCallbackOneLoginClient interface {
	Exchange(ctx context.Context, code, nonce string) (idToken, accessToken string, err error)
	UserInfo(ctx context.Context, accessToken string) (onelogin.UserInfo, error)
}

type LoginCallbackSessionStore added in v0.1051.0

type LoginCallbackSessionStore interface {
	OneLogin(r *http.Request) (*sesh.OneLoginSession, error)
	SetLogin(r *http.Request, w http.ResponseWriter, session *sesh.LoginSession) error
}

type LoginOneLoginClient

type LoginOneLoginClient interface {
	AuthCodeURL(state, nonce, locale string, confidenceLevel onelogin.ConfidenceLevel) (string, error)
}

type LoginSessionStore added in v0.1051.0

type LoginSessionStore interface {
	SetOneLogin(r *http.Request, w http.ResponseWriter, session *sesh.OneLoginSession) error
}

type LpaStoreResolvingService added in v0.1868.33

type LpaStoreResolvingService interface {
	Get(ctx context.Context) (*lpadata.Lpa, error)
}

type Notification added in v0.1829.0

type Notification struct {
	Heading  string
	BodyHTML string
}

type OneLoginClient

type OneLoginClient interface {
	AuthCodeURL(state, nonce, locale string, confidenceLevel onelogin.ConfidenceLevel) (string, error)
	EndSessionURL(idToken, postLogoutURL string) (string, error)
	Exchange(ctx context.Context, code, nonce string) (idToken, accessToken string, err error)
	UserInfo(ctx context.Context, accessToken string) (onelogin.UserInfo, error)
}

type Path

type Path string

func (Path) Format

func (p Path) Format() string

func (Path) Redirect added in v0.833.0

func (p Path) Redirect(w http.ResponseWriter, r *http.Request, appData appcontext.Data) error

func (Path) RedirectQuery added in v0.833.0

func (p Path) RedirectQuery(w http.ResponseWriter, r *http.Request, appData appcontext.Data, query url.Values) error

func (Path) String

func (p Path) String() string

type SessionStore

type SessionStore interface {
	Csrf(r *http.Request) (*sesh.CsrfSession, error)
	SetCsrf(r *http.Request, w http.ResponseWriter, session *sesh.CsrfSession) error
	Login(r *http.Request) (*sesh.LoginSession, error)
	SetLogin(r *http.Request, w http.ResponseWriter, session *sesh.LoginSession) error
	ClearLogin(r *http.Request, w http.ResponseWriter) error
	OneLogin(r *http.Request) (*sesh.OneLoginSession, error)
	SetOneLogin(r *http.Request, w http.ResponseWriter, session *sesh.OneLoginSession) error
}

type SetLpaDataSessionStore added in v0.1868.33

type SetLpaDataSessionStore interface {
	SetLpaData(r *http.Request, w http.ResponseWriter, lpaDataSession *sesh.LpaDataSession) error
}

type Template

type Template func(io.Writer, interface{}) error

type UpdateLoginSessionStore added in v0.1868.33

type UpdateLoginSessionStore interface {
	Login(r *http.Request) (*sesh.LoginSession, error)
	SetLogin(r *http.Request, w http.ResponseWriter, session *sesh.LoginSession) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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