Documentation
¶
Overview ¶
Package devlogin signs people in for trying a server on one's own computer, and checks no one's identity: a page that lists the people of the organization, where the one chosen is who sends each request from then on (SignIn), and the header X-Person, for trying the API with a client such as curl (Header). It also has the checks that keep the two away from a server that serves people: they answer only a request sent on the computer the server runs on (Local), a server takes them only when it listens on a loopback address (OnLoopback), and not where the environment has the settings of signing in through the provider (NotWithProvider). Package serve uses them for -dev-login and for the header it takes when no other way of signing in is chosen.
Index ¶
Constants ¶
const ( Cookie = "ringi-dev-person" RolesCookie = "ringi-dev-roles" LoginPath = "/login" LogoutPath = "/logout" )
The cookies that name the person and their roles, and the paths of signing in and out.
Variables ¶
var ProviderSettings = []string{"RINGI_OIDC_CLIENT_SECRET", "RINGI_SESSION_KEYS"}
ProviderSettings are the environment variables of signing in through the provider that a server's command line reads (package serve: -oidc-client-secret and -session-keys): a process that has one is set up to serve people.
Functions ¶
func Local ¶
Local reports whether a request was sent on the computer the server runs on: its Host is a loopback address, and it has none of the headers a proxy adds to what it forwards. A proxy in front of a server that listens on a loopback address would otherwise bring other computers' requests to a sign-in that checks no one, under a Host it may have set to the server's address. (A proxy that adds none of them is not seen: these sign-ins are never put behind one.)
func Loopback ¶
Loopback reports whether a request's Host (a name or an address, with or without a port) is a loopback address: localhost, 127.0.0.0/8 or ::1.
func NotWithProvider ¶
NotWithProvider answers an error when the environment (getenv) has one of ProviderSettings: a way of signing in that checks no one (what names it, for the error) does not run in a process set up to sign people in through the provider, where a flag left out would otherwise let anyone be anyone.
func OnLoopback ¶
OnLoopback answers an error unless addr, an address to listen on (host:port), is a loopback one. A server takes a way of signing in that checks no one (the header X-Person, -dev-login, an agents' token that is a person's ID) only on such an address: what checks no one must not be reachable from another computer. what names the way, for the error.
func Roles ¶
Roles reads roles written separated by commas, as the header X-Roles and the page of signing in take them: each trimmed of spaces, an empty one left out, one written twice kept once. ok is false for more than 16 roles, or one longer than 64 bytes or with a character that is not visible ASCII.
Types ¶
type Header ¶
type Header struct{}
Header signs in by the header X-Person, which names who sends a request (X-Roles their roles, separated by commas, as Roles reads them; staff when it is not sent, and no one when it cannot be read), only on a Local request: for trying the API with a client such as curl. It checks no one, as SignIn does: a server uses it only when it listens on a loopback address (OnLoopback), and a request whose Host is another name (a page of another site that made a browser send it to this computer under its own name) or that a proxy forwarded has no person.
type SignIn ¶
type SignIn struct {
// Server is the server whose organization's people may be chosen.
Server *server.Server
}
SignIn signs people in on the computer the server runs on, for trying a server in a browser: its page lists the people of the organization, and the one chosen is who sends each request from then on (a cookie names them), with the roles chosen under the list (another cookie: none when none is chosen), for trying what the gate lets each role do: a link for each role that the gate of the examples declares, as the gate of a project ritsu ringi init makes does, opens the page with the role written (?roles=). An organization of more people than a picker of the pages lists (web.PicksListed) is not listed: the page finds people by a part of a name or an ID, as such a picker does, with no script. It checks no one's identity, so it answers only requests sent to a loopback address (localhost, 127.0.0.1, ::1) that no proxy forwarded (Local); a server starts it only when it listens on one (OnLoopback), and not where the environment has the provider's settings (NotWithProvider), as package serve does with -dev-login. It is a server.Authenticator, and it gives the pages the hooks of a sign-in (web.Config's Require, LoginURL and SignOut).
func (*SignIn) Authenticate ¶
Authenticate answers the person the cookie names, while the organization in effect today has them, with the roles they signed in with (none when they gave none: the gate takes them as it takes one with no role): server.ErrNoPerson with no cookie, for someone the organization does not have, and for a request that is not Local.
func (*SignIn) LoginURL ¶
LoginURL answers the address of signing in that comes back to returnTo, a path of this server.