{"modulePath":"github.com/2lambda123/openshift-origin","version":"v4.1.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package tokencmd\n\n## Functions\n\n```go\nfunc GSSAPIEnabled() bool\n```\n\n```go\nfunc RequestToken(clientCfg *restclient.Config, reader io.Reader, defaultUsername string, defaultPassword string) (string, error)\n```\nRequestToken uses the cmd arguments to locate an openshift oauth server and attempts to authenticate via an OAuth code flow and challenge handling.  It returns the access token if it gets one or an error if it does not.\n\n```go\nfunc SSPIEnabled() bool\n```\n\n## Types\n\n```go\ntype BasicChallengeHandler struct {\n\t// Host is the server being authenticated to. Used only for displaying messages when prompting for username/password\n\tHost string\n\n\t// Reader is used to prompt for username/password. If nil, no prompting is done\n\tReader io.Reader\n\t// Writer is used to output prompts. If nil, stdout is used\n\tWriter io.Writer\n\n\t// Username is the username to use when challenged. If empty, a prompt is issued to a non-nil Reader\n\tUsername string\n\t// Password is the password to use when challenged. If empty, a prompt is issued to a non-nil Reader\n\tPassword string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (c *BasicChallengeHandler) CanHandle(headers http.Header) bool\n```\n\n```go\nfunc (c *BasicChallengeHandler) CompleteChallenge(requestURL string, headers http.Header) error\n```\n\n```go\nfunc (c *BasicChallengeHandler) HandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error)\n```\n\n```go\nfunc (c *BasicChallengeHandler) Release() error\n```\n\n```go\ntype ChallengeHandler interface {\n\t// CanHandle returns true if the handler recognizes a challenge it thinks it can handle.\n\tCanHandle(headers http.Header) bool\n\t// HandleChallenge lets the handler attempt to handle a challenge.\n\t// It is only invoked if CanHandle() returned true for the given headers.\n\t// Returns response headers and true if the challenge is successfully handled.\n\t// Returns false if the challenge was not handled, and an optional error in error cases.\n\tHandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error)\n\t// CompleteChallenge is invoked with the headers from a successful server response\n\t// received after having handled one or more challenges.\n\t// Returns an error if the handler does not consider the challenge/response interaction complete.\n\tCompleteChallenge(requestURL string, headers http.Header) error\n\t// Release gives the handler a chance to release any resources held during a challenge/response sequence.\n\t// It is always invoked, even in cases where no challenges were received or handled.\n\tRelease() error\n}\n```\nChallengeHandler handles responses to WWW-Authenticate challenges.\n\n```go\nfunc NewMultiHandler(handlers ...ChallengeHandler) ChallengeHandler\n```\n\n```go\nfunc NewNegotiateChallengeHandler(negotiator Negotiator) ChallengeHandler\n```\n\n```go\ntype MultiHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nMultiHandler manages a series of authentication challenges it is single-use only, and not thread-safe\n\n```go\nfunc (h *MultiHandler) CanHandle(headers http.Header) bool\n```\n\n```go\nfunc (h *MultiHandler) CompleteChallenge(requestURL string, headers http.Header) error\n```\n\n```go\nfunc (h *MultiHandler) HandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error)\n```\n\n```go\nfunc (h *MultiHandler) Release() error\n```\n\n```go\ntype NegotiateChallengeHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nNegotiateChallengeHandler manages a challenge negotiation session it is single-host, single-use only, and not thread-safe\n\n```go\nfunc (c *NegotiateChallengeHandler) CanHandle(headers http.Header) bool\n```\n\n```go\nfunc (c *NegotiateChallengeHandler) CompleteChallenge(requestURL string, headers http.Header) error\n```\n\n```go\nfunc (c *NegotiateChallengeHandler) HandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error)\n```\n\n```go\nfunc (c *NegotiateChallengeHandler) Release() error\n```\n\n```go\ntype Negotiator interface {\n\t// Load gives the negotiator a chance to load any resources needed to handle a challenge/response sequence.\n\t// It may be invoked multiple times. If an error is returned, InitSecContext and IsComplete are not called, but Release() is.\n\tLoad() error\n\t// InitSecContext returns the response token for a Negotiate challenge token from a given URL,\n\t// or an error if no response token could be obtained or the incoming token is invalid.\n\tInitSecContext(requestURL string, challengeToken []byte) (tokenToSend []byte, err error)\n\t// IsComplete returns true if the negotiator is satisfied with the negotiation.\n\t// This typically means gssapi returned GSS_S_COMPLETE to an initSecContext call.\n\tIsComplete() bool\n\t// Release gives the negotiator a chance to release any resources held during a challenge/response sequence.\n\t// It is always invoked, even in cases where no challenges were received or handled.\n\tRelease() error\n}\n```\nNegotiator defines the minimal interface needed to interact with GSSAPI to perform a negotiate challenge/response\n\n```go\nfunc NewGSSAPINegotiator(string) Negotiator\n```\n\n```go\nfunc NewSSPINegotiator(string, string, string, io.Reader) Negotiator\n```\n\n```go\ntype RequestTokenOptions struct {\n\tClientConfig *restclient.Config\n\tHandler      ChallengeHandler\n\tOsinConfig   *osincli.ClientConfig\n\tIssuer       string\n\tTokenFlow    bool\n}\n```\n\n```go\nfunc NewRequestTokenOptions(clientCfg *restclient.Config, reader io.Reader, defaultUsername string, defaultPassword string, tokenFlow bool) *RequestTokenOptions\n```\n\n```go\nfunc (o *RequestTokenOptions) RequestToken() (string, error)\n```\nRequestToken locates an openshift oauth server and attempts to authenticate. It returns the access token if it gets one, or an error if it does not. It should only be invoked once on a given RequestTokenOptions instance. The Handler held by the options is released as part of this call. If RequestTokenOptions.OsinConfig is nil, it will be defaulted using SetDefaultOsinConfig. The caller is responsible for setting up the entire OsinConfig if the value is not nil.\n\n```go\nfunc (o *RequestTokenOptions) SetDefaultOsinConfig() error\n```\nSetDefaultOsinConfig overwrites RequestTokenOptions.OsinConfig with the default CLI OAuth client and PKCE support if the server supports S256 / a code flow is being used\n\n","path":"github.com/2lambda123/openshift-origin/pkg/oc/lib/tokencmd","name":"tokencmd","synopsis":"","isRedistributable":true}
