Documentation
¶
Overview ¶
Package auth implements the device-code login flow against the cloud API.
Index ¶
- type Credentials
- type Service
- func (s Service) LoginWithBrowser(ctx context.Context, cfg *config.Config, w io.Writer) (Credentials, error)
- func (s Service) LoginWithToken(ctx context.Context, cfg *config.Config, token, project string) (Credentials, error)
- func (s Service) Logout() error
- func (s Service) Signup(ctx context.Context, cfg *config.Config, email string, w io.Writer) (Credentials, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct {
Token string
UserID string
// Project is the project login validated the token against, to be saved as
// the active project. Nil when login resolved no project.
Project *config.ProjectConfig
}
Credentials are the platform credentials produced by a successful login.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs Volcano authentication workflows.
func NewService ¶
func NewService(deps cliruntime.Deps) Service
NewService returns an authentication service.
func (Service) LoginWithBrowser ¶
func (s Service) LoginWithBrowser(ctx context.Context, cfg *config.Config, w io.Writer) (Credentials, error)
LoginWithBrowser runs the OAuth device flow and opens the browser at the verification URI the device-authorization response returned, unmodified. That page (for Volcano's first-party CLI client, the API's own managed hosted-auth page, action=device) is self-contained: it signs the user in and asks them to approve the code itself, so login needs no Volcano Web routing of its own (see docs/api-reference/cli-authentication.md and docs/authentication/managed-hosted-pages.md in volcano-hosting).
func (Service) LoginWithToken ¶
func (s Service) LoginWithToken(ctx context.Context, cfg *config.Config, token, project string) (Credentials, error)
LoginWithToken validates token and returns credentials to persist. project names the project to validate against and select, by ID or by name; it is optional for an account token and required for a project access token, which cannot list projects and so cannot tell the CLI which project it belongs to.
func (Service) Signup ¶ added in v0.0.4
func (s Service) Signup(ctx context.Context, cfg *config.Config, email string, w io.Writer) (Credentials, error)
Signup routes the browser through Volcano Web's own signup page (account creation isn't something the device-authorization response's verification page handles), then to a same-origin /device path. cfg.WebURLForAPIURL (explicit VOLCANO_WEB_URL, else derived from apiURL, else the compiled default) is the signup origin: the verification response's own URI can't be used for this, since for Volcano's first-party CLI client it now points at the API's own managed-hosted-auth page (a different origin, per docs/api-reference/cli-authentication.md in volcano-hosting), and Volcano Web's signup page only accepts a same-origin relative `next` value anyway (isSafeInternalPath in volcano-web rejects absolute URLs).