Documentation
¶
Overview ¶
Package login implements the interactive browser-based Aula login via MitID: it opens a visible Chrome/Chromium window, polls for the PHPSESSID cookie, handles Aula's "secure login" step-up through the UNI-Login SAML broker, and delivers QR code screenshots while the user has not completed the login.
Two login methods are supported — the flow is identical, the user simply picks whichever matches their MitID setup:
- MitID app: scan the QR code shown in the browser window (or in the screenshot delivered via Options.OnQR / Snapshot.QR) with the app on the phone.
- MitID code reader: ignore the QR code and log in with username, password and the physical code reader.
The package backs both the goaula-login CLI and the goaula-mcp login tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// StartURL is the Aula URL to open (default https://www.aula.dk/).
StartURL string
// Headless runs the browser without a visible window; the QR code is
// then only available via the screenshots.
Headless bool
// BrowserPath overrides browser auto-detection.
BrowserPath string
// Settle is how long the session token must stay unchanged before it is
// considered final (default 10s). Aula rotates the token once during
// the secure-login step-up.
Settle time.Duration
// Timeout is the overall deadline of the login flow (default 10m).
Timeout time.Duration
// SkipStepUp skips the secure-login step-up (session will have the
// basic authentication level).
SkipStepUp bool
// QRPath is an optional file to write each QR screenshot to.
QRPath string
// OnQR, when set, is called with each fresh QR screenshot (in addition
// to the snapshot delivered via Poll).
OnQR func(png []byte)
}
Options configures a login flow. Zero values select the defaults.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages one interactive login flow. Create one with NewSession, start it with Start, and receive state changes with Poll. A Session can only be started once.
func NewSession ¶
NewSession creates a login flow with the given options.
func (*Session) Close ¶
func (s *Session) Close()
Close cancels the login flow (if still running) and closes the browser.
type Snapshot ¶
type Snapshot struct {
Status Status
SessionID string // set when Status == StatusAuthenticated
QR []byte // PNG screenshot of a fresh QR code, if any
Err error // set when the flow failed unrecoverably
}
Snapshot is a state change of a login flow, delivered by Session.Poll.
type Status ¶
type Status int
Status describes the state of a login flow.
const ( // StatusWaiting means login is still in progress. QR is non-nil when a // fresh QR code screenshot just became available. StatusWaiting Status = iota // StatusAuthenticated means login (including the step-up, unless // disabled) completed and the session was captured. StatusAuthenticated // StatusBrowserClosed means the user closed the browser before // completing the login. StatusBrowserClosed )