login

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func NewSession(opts Options) *Session

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.

func (*Session) Poll

func (s *Session) Poll(timeout time.Duration) Snapshot

Poll waits up to timeout for the next state change of the login flow and returns it. When nothing changes within the timeout it returns StatusWaiting (the caller can simply call Poll again).

func (*Session) Start

func (s *Session) Start()

Start launches the browser and begins the login flow in a background goroutine. It is idempotent; use Poll to receive the results.

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
)

Jump to

Keyboard shortcuts

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