Documentation
¶
Index ¶
- func CookieStateChanged(before, after CookieState) bool
- func ExpandCredentials(value, username, password string) string
- func FirstNavigateURL(steps []LoginStep) string
- func HasTerminalVisibleAssertion(steps []LoginStep) bool
- func NeedsCredentials(steps []LoginStep) bool
- func RunLoginSteps(ctx context.Context, page *rod.Page, steps []LoginStep, ...) error
- func SessionStateChanged(before, after SessionState) bool
- func ValidateSteps(steps []LoginStep) error
- type CookieState
- type LoginStep
- func StepsAfterFirstNavigateURL(steps []LoginStep) ([]LoginStep, string)
- func StepsFromData(data []byte, username, password string) ([]LoginStep, error)
- func StepsFromExplicit(data []byte) ([]LoginStep, error)
- func StepsFromFile(path, username, password string) ([]LoginStep, error)
- func StepsFromRecording(data []byte, username, password string) ([]LoginStep, error)
- type SessionState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CookieStateChanged ¶
func CookieStateChanged(before, after CookieState) bool
CookieStateChanged reports whether a cookie was added or its value changed. Deletions alone do not prove authentication.
func ExpandCredentials ¶
ExpandCredentials substitutes {{username}}/{{password}} placeholders.
func FirstNavigateURL ¶
FirstNavigateURL returns the first absolute HTTP(S) navigate URL, or "". Recorder exports can contain an initial about:blank navigation, which is not a useful anonymous-session baseline.
func HasTerminalVisibleAssertion ¶
HasTerminalVisibleAssertion reports whether the flow ends by asserting an authenticated-only element. This is an explicit success signal for applications whose server-side session does not mutate browser state.
func NeedsCredentials ¶
NeedsCredentials reports whether any step value still contains an unresolved credential placeholder that must be supplied via -auto-login.
func RunLoginSteps ¶
func RunLoginSteps(ctx context.Context, page *rod.Page, steps []LoginStep, username, password string, settle time.Duration) error
RunLoginSteps replays an explicit multi-step login flow against a rod page. Cookies / storage set during replay remain on the browser context for the subsequent crawl. settle bounds waitvisible / inter-step WaitStable; zero uses a 5s default.
func SessionStateChanged ¶
func SessionStateChanged(before, after SessionState) bool
SessionStateChanged reports evidence that replay established browser auth.
func ValidateSteps ¶
ValidateSteps rejects flows that cannot be replayed deterministically.
Types ¶
type CookieState ¶
CookieState is a browser-wide snapshot used to verify that a login changed authentication state. Cookies are browser-wide because SSO flows can finish on a different origin from the application login page.
func CaptureCookieState ¶
func CaptureCookieState(page *rod.Page) (CookieState, error)
CaptureCookieState snapshots cookie values without exposing them to logs.
type LoginStep ¶
type LoginStep struct {
// Action is one of: navigate, fill, click, doubleclick, waitvisible, wait,
// press, submit.
Action string `json:"action" yaml:"action"`
// Selector is a CSS selector (or xpath=… expression) the action targets.
// Unused by navigate/wait.
Selector string `json:"selector" yaml:"selector"`
// Value is the action argument: a URL (navigate), text to type (fill), a key
// name such as "enter"/"tab" (press), or a duration like "2s" (wait).
Value string `json:"value" yaml:"value"`
}
LoginStep is a single action in a multi-step headless login flow. In Value, the placeholders {{username}} and {{password}} are substituted with the configured credentials so secrets stay out of the step list / recording.
func StepsAfterFirstNavigateURL ¶
StepsAfterFirstNavigateURL returns the replayable suffix after the first absolute HTTP(S) navigation. The caller can navigate once, capture the anonymous cookie baseline, and avoid loading the login page a second time.
func StepsFromData ¶
StepsFromData converts a recording / explicit-step JSON payload into LoginSteps.
func StepsFromExplicit ¶
StepsFromExplicit loads a hand-authored LoginStep list.
func StepsFromFile ¶
StepsFromFile loads either a Chrome DevTools Recorder export or an explicit { "steps": [ { "action": ... } ] } JSON file.
func StepsFromRecording ¶
StepsFromRecording converts a Chrome DevTools Recorder export into LoginSteps. username/password are used to parameterize captured credential literals into {{username}}/{{password}} placeholders.
type SessionState ¶
type SessionState struct {
Cookies CookieState
Origin string
LocalStorage string
SessionStorage string
// StorageCaptured distinguishes empty storage from a failed read, so a
// failed read is never mistaken for storage having changed.
StorageCaptured bool
}
SessionState captures the browser state commonly used to persist web authentication. Storage is compared only while the flow remains on the same origin; cookies are browser-wide and cover cross-origin SSO redirects.
func CaptureSessionState ¶
func CaptureSessionState(page *rod.Page) (SessionState, error)
CaptureSessionState snapshots cookies plus same-origin web storage.