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 ¶
const LoginAgain = "native:login"
LoginAgain is what LoginURL returns: the native console has no page to go to, it logs in again.
const MaxInUse = client.MaxInUse
MaxInUse is how many servers' tokens one refresh asks for: the ones most recently used (see client.MaxInUse).
Variables ¶
var ErrNotLoggedIn = client.ErrNotLoggedIn
ErrNotLoggedIn is the answer when there is no session, or it has ended. It is the portal client's own, so that errors.Is recognises both.
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 Direct ¶ added in v0.2.0
type Direct struct {
// contains filtered or unexported fields
}
Direct is a Backend that logs in itself -- through the system browser and a loopback listener (go-authn/rp, RFC 8252) -- and calls each server with a token addressed to it alone. The refresh token stays in this process's memory, and one refresh runs at a time: the provider rotates a public client's refresh tokens and ends the login when one is spent twice.
func NewDirect ¶ added in v0.2.0
NewDirect is a Backend over cfg. open shows a URL to the person -- the system browser (rp.OpenBrowser).
func (*Direct) Client ¶ added in v0.2.0
func (d *Direct) Client(server string) adminv1connect.AdminServiceClient
Client is the admin API of server, called directly with its own token.
func (*Direct) LoginURL ¶ added in v0.2.0
LoginURL is LoginAgain: there is no page to send a native app to.
type DirectConfig ¶ added in v0.2.0
type DirectConfig struct {
Issuer string
ClientID string // a PUBLIC client: no secret (RFC 8252 §8.5)
Scopes []string
Servers []DirectServer
}
DirectConfig is what a native console needs to reach servers on its own, without a portal: where to log in, and the servers.
type DirectServer ¶ added in v0.2.0
type DirectServer struct {
ID, Label string
URL string // the admin block's web listener
Issuer string
Resource string // RFC 8707: the token's audience, the server's issuer audience
Scope string // for a provider that sets the audience from a scope
CAFile string // when its certificate is not publicly trusted
}
DirectServer is one fileshare server's admin API over HTTPS.
type Portal ¶
type Portal struct {
// contains filtered or unexported fields
}
Portal is a Backend through go-fileshare/portal, by its client package (go-fileshare/portal/client): the same session, refresh and CSRF handling as the explorer's.
func NewPortal ¶
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; in a browser it is client.WebLocks, which serializes them across tabs.
func (*Portal) Client ¶
func (p *Portal) Client(server string) adminv1connect.AdminServiceClient
Client is the admin API of server, through the portal.
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. |