Help us shape the future of Go! Take the 2026 Go Developer Survey

admin

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package admin is how the console reaches fileshare servers: their admin API (fileshare.admin.v1.AdminService, over Connect), and who is logged in.

In a browser it goes through go-fileshare/portal, which holds the tokens: the console sends its calls to /api/<server>/..., with the session cookie the browser adds and the static header the portal requires, and never sees a token.

Index

Constants

View Source
const MaxInUse = 5

MaxInUse is how many servers' tokens one refresh asks for: the ones most recently used. The portal keeps its session in cookies, and a browser sends those on one header line that a load balancer bounds (8 KiB at nginx's default); five tokens of about 1 KB fit. Calling a sixth server makes the least recently used one ask again when it is next called.

Variables

View Source
var ErrNotLoggedIn = errors.New("not logged in")

ErrNotLoggedIn is the answer when there is no session, or it has ended.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Session(ctx context.Context) (*Session, error)
	// Client is the admin API of one server.
	Client(server string) adminv1connect.AdminServiceClient
	// Logout ends the session, and returns where the browser should go
	// next to end it at the identity provider too ("" if nowhere).
	Logout(ctx context.Context) (string, error)
	// LoginURL is where to send a browser that has no session.
	LoginURL(returnTo string) string
}

A Backend is what the console needs.

type Portal

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

Portal is a Backend through go-fileshare/portal.

func NewPortal

func NewPortal(base string, hc *http.Client, serialize func(func() error) error) *Portal

NewPortal is a Backend through the portal at base (an origin, such as "https://files.example.org", or "" for the page's own). serialize may be nil: refreshes are then serialized within this process only.

func (*Portal) Client

func (p *Portal) Client(server string) adminv1connect.AdminServiceClient

Client is the admin API of server, through the portal.

func (*Portal) LoginURL

func (p *Portal) LoginURL(returnTo string) string

LoginURL is the portal's login, coming back to returnTo (a path).

func (*Portal) Logout

func (p *Portal) Logout(ctx context.Context) (string, error)

Logout ends the session.

func (*Portal) Session

func (p *Portal) Session(ctx context.Context) (*Session, error)

Session is who is logged in.

type Server

type Server struct {
	ID    string
	Label string
	// Reachable: its tokens come from the identity provider this session
	// logged in with. A server behind another provider is listed, not
	// reachable.
	Reachable bool
}

A Server is one fileshare server the console can manage.

func (Server) Name

func (s Server) Name() string

Name is how the console shows the server.

type Session

type Session struct {
	Issuer, Subject, Name string
	Expires               time.Time
	Servers               []Server
}

A Session is who is logged in, and which servers they can reach.

func (*Session) Who

func (s *Session) Who() string

Who is how the console names the person.

Directories

Path Synopsis
Package admintest is a stand-in for go-fileshare/portal and the fileshare servers behind it, for tests: in one process, with the portal's rules where the console depends on them.
Package admintest is a stand-in for go-fileshare/portal and the fileshare servers behind it, for tests: in one process, with the portal's rules where the console depends on them.

Jump to

Keyboard shortcuts

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