Documentation
¶
Overview ¶
Package login is doit's view of goclilogin: where the service is, which client this machine logs in as, and where its token and refresh lock live.
Each identifier below matches pyclilogin's for the product "doit": the config file, the keychain entry, the fallback token file and the refresh lock. A desk's login lives under them, so renaming any one logs that desk out.
Index ¶
- Constants
- Variables
- func Config(d goclilogin.Deployment) goclilogin.Config
- func DefaultClientID() string
- func ForLogin(ctx context.Context, api, clientID string) (goclilogin.Deployment, error)
- func Load(ctx context.Context) (goclilogin.Deployment, error)
- func Path() string
- func TokenSource(ctx context.Context, d goclilogin.Deployment, store *goclilogin.TokenStore) (oauth2.TokenSource, error)
Constants ¶
const ClientSecretVariable = "DOIT_CLIENT_SECRET"
ClientSecretVariable is pyclilogin's name for a service client's secret, `<PRODUCT>_CLIENT_SECRET`.
const KeyringService = "doit-cli"
KeyringService namespaces doit's entries in the OS keychain. It is a deployed identifier: renaming it orphans every stored token.
const Product = "doit"
Product names the config file's directory and the state directory.
Variables ¶
var ErrNeedsLogin = errors.New("this machine is not logged in to doit's service; run `doit auth login`")
ErrNeedsLogin is a person's machine holding no token, which `doit auth login` fixes.
Functions ¶
func Config ¶
func Config(d goclilogin.Deployment) goclilogin.Config
Config is the goclilogin view of a deployment.
StateDir is pyclilogin's, $XDG_STATE_HOME/doit, rather than goclilogin's default under the keyring service's name. Two directories would mean two refresh locks, and a refresh token rotated by one side would then fail on the other.
func DefaultClientID ¶
func DefaultClientID() string
DefaultClientID is the client login names where neither the file nor --client-id does: doit-cli-<short hostname>.
func ForLogin ¶
func ForLogin(ctx context.Context, api, clientID string) (goclilogin.Deployment, error)
ForLogin is the deployment `doit auth login` logs in to: the file's values, with whatever it lacks filled in from api, the service's metadata and clientID.
func Load ¶
func Load(ctx context.Context) (goclilogin.Deployment, error)
Load reads the service's deployment from the config file.
func TokenSource ¶
func TokenSource(ctx context.Context, d goclilogin.Deployment, store *goclilogin.TokenStore) (oauth2.TokenSource, error)
TokenSource is where every request's token comes from: the config file's token_command where it sets one, else the token this machine logged in for.
Types ¶
This section is empty.