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

direct

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package direct is the native explorer's way to the servers: no portal. It logs in itself -- the system browser and a loopback listener, as a public client (go-authn/rp, RFC 8252) -- and calls each server's WebDAV with a token addressed to that server alone (RFC 8707). A browser page goes through the portal instead, and never links any of this.

Index

Constants

View Source
const LoginAgain = "native:login"

LoginAgain is what LoginURL returns: a native window has no page to go to; its host logs in again when told to navigate there.

View Source
const MaxBody = 16 << 20

MaxBody bounds one request body, kept to be sent again after a refresh: the explorer's upload pieces are 8 MiB.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend logs in once, keeps the refresh token in this process's memory only, and spends it one refresh at a time: a provider rotates a public client's refresh tokens and ends the login when one is spent twice.

func New

func New(cfg Config, open func(string) error, hc *http.Client) (*Backend, error)

New is a Backend over cfg. open shows a URL to the person: the system browser (rp.OpenBrowser).

func (*Backend) DAV

func (b *Backend) DAV(server string) *dav.Client

DAV is server's WebDAV, called directly with its own token.

func (*Backend) EnsureToken

func (b *Backend) EnsureToken(ctx context.Context, server string) error

EnsureToken makes sure a current token for server is held.

func (*Backend) LoginURL

func (b *Backend) LoginURL(string) string

LoginURL is LoginAgain: there is no page to send a native window to.

func (*Backend) Logout

func (b *Backend) Logout(context.Context) (string, error)

Logout forgets the login, and returns where to end the session at the provider, if it says.

func (*Backend) Session

func (b *Backend) Session(ctx context.Context) (*client.Session, error)

Session logs in, the first time, and says who and which servers.

type Config

type Config struct {
	Issuer   string
	ClientID string // a PUBLIC client: no secret (RFC 8252 §8.5)
	Scopes   []string
	Servers  []Server
}

Config is what the native explorer needs to reach servers on its own: where to log in, and the servers -- what a portal would know.

type Server

type Server struct {
	ID, Label string
	DAVURL    string // its WebDAV, over https
	Resource  string // RFC 8707: the audience of its oidc block
	Scope     string // for a provider that sets the audience from a scope
	CAFile    string // when its certificate is not publicly trusted
}

Server is one fileshare server's WebDAV.

Jump to

Keyboard shortcuts

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