demo

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 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 demo is a credentials.Broker that needs no accounts: its consent page is a local web page, and the only provider API it fakes is Google Calendar event creation. It exists so the AUTH_REQUIRED flow can be run and tested end to end.

Index

Constants

View Source
const CalendarEventsPath = "/calendar/v3/calendars/primary/events"

CalendarEventsPath is the Google Calendar API path the demo grant understands.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker is the demo credentials broker.

func New

func New(baseURL string) *Broker

New creates a demo broker whose pages are served under baseURL, for example "http://localhost:8088/demo-auth". Mount Handler at that path.

func (*Broker) Await

Await implements credentials.Broker.

func (*Broker) Begin

func (b *Broker) Begin(ctx context.Context, user, integration string) (*credentials.Challenge, error)

Begin implements credentials.Broker.

func (*Broker) Decide

func (b *Broker) Decide(id string, allow bool) error

Decide completes a challenge as if the user clicked Allow or Deny.

func (*Broker) Events

func (b *Broker) Events() []CalendarEvent

Events returns the calendar events created through demo grants.

func (*Broker) Handler

func (b *Broker) Handler() http.Handler

Handler serves the consent page (/connect/{id}) and the fake calendar (/calendar). Mount it with http.StripPrefix at the path of baseURL.

func (*Broker) Lookup

func (b *Broker) Lookup(ctx context.Context, user, integration string) (credentials.Grant, error)

Lookup implements credentials.Broker.

type CalendarEvent

type CalendarEvent struct {
	ID          string    `json:"id"`
	User        string    `json:"user"`
	Summary     string    `json:"summary"`
	Description string    `json:"description,omitempty"`
	Start       EventDate `json:"start"`
	End         EventDate `json:"end"`
	Created     time.Time `json:"created"`
}

CalendarEvent is the subset of a Google Calendar event the demo stores.

type EventDate

type EventDate struct {
	Date string `json:"date"`
}

EventDate is an all-day date, as in Google Calendar's {"date": "2026-11-20"}.

Jump to

Keyboard shortcuts

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