UNPKG

@zowe/imperative

Version:
143 lines 6.06 kB
import { ICommandArguments } from "../../../cmd"; import { ISession } from "./doc/ISession"; /** * The purpose of this class is to detect an authentication order property * supplied by a user in a profile, command line, or environment variable. * That authOrder is then used to place the correct set of credentials into * a session for authentication. * * To accomplish this behavior, we call AuthOrder.addCredsToSession * early in the processing of a command (when both a session * configuration and command arguments are available). For example in: * ConnectionPropsForSessCfg.addPropsOrPrompt or * ProfileInfo.createSession * * Before we use the session, we call AuthOrder.putTopAuthInSession. * For example in: * AbstractRestClient.constructor * AbstractRestClient.request * AuthOrder.putTopAuthInSession ensures that the session only contains the * credentials for the desired type of authentication. */ export declare class AuthOrder { private static readonly SESS_CERT_NAME; private static readonly SESS_CERT_KEY_NAME; private static readonly ARRAY_OF_CREDS; /** * Add available credentials (and the authentication order in which * credentials should be chosen) into a cache within the specified session. * Using that cached information put only the top selected credential as * the credential to be used by the session. * * @param sessCfg - Modified. * A session configuration object into which we place cached creds * and the selected creds. * * @param cmdArgs - Input. * The set of arguments with which the calling function is operating. * For CLI, the cmdArgs come from the command line, profile, or * environment. Other apps can place relevant arguments into this * object to be processed by this function. * * If cmdArgs is not supplied, we only cache creds found in the sessCfg. */ static addCredsToSession<SessCfgType extends ISession>(sessCfg: SessCfgType, cmdArgs?: ICommandArguments): void; /** * Record that the session is being used to make a request for a token * (ie logging into APIML). * * @param sessCfg - Modified. * The session config into which we record that we are requesting a token. */ static makingRequestForToken<SessCfgType extends ISession>(sessCfg: SessCfgType): void; /** * Cache all of the credentials that are available in either the supplied * sessCfg object or in the supplied command arguments. Also cache the * authOrder that is specified in the supplied command arguments. The * cache properties are stored into the sessCfg object itself. * * Downstream logic uses this cache to determine which auth type should be * used in the final session used by a client REST request. * * @param sessCfg - Modified. * A session configuration object to which we place the cached creds. * * @param cmdArgs - Input. * The set of arguments with which the calling function is operating. * For CLI, the cmdArgs come from the command line, profile, or * environment. Other apps can place relevant arguments into this * object to be processed by this function. * * If cmdArgs is not supplied, we only cache creds found in the sessCfg. */ private static cacheCredsAndAuthOrder; /** * Cache the authOrder property from the supplied cmdArgs. If no authOrder exists * in cmdArgs, a default authOrder is created and cached. * * @param sessCfg - Modified. * A session configuration object into which we store the auth cache. * * @param cmdArgs - Input. * The set of arguments that the calling function is using. */ private static cacheAuthOrder; /** * Cache the named credential into our cache of available credentials. * * @param sessCredName - Input. * The name of a cred to be cached in a session. * * @param sessCfg - Modified. * A session configuration object. * * @param cmdArgs - Input. * The set of arguments with which the calling function is operating. */ private static cacheCred; /** * Choose a default authentication order and place it into the session sessCfg. * * Other classes in the Zowe client API (like AbstractRestClient) call * cacheDefaultAuthOrder to specify the top default authentication type. * If so, we keep any topDefaultAuth that has already been set. * * If topDefaultAuth has NOT been set, we set basic authentication as the * topDefaultAuth. * * @param sessCfg - Modified. * A session configuration object. */ private static chooseDefaultAuthOrder; /** * Find the auth cache in the session config. If there is no cache * recorded in the session config, create a new auth cache entry. * * @param sessCfg - Input. * A session configuration object into which we record any newly created cache. */ private static findOrCreateAuthCache; /** * Keep the specified credential by deleting it from the set of * credentials to remove. * * @param credToKeep - Input. * The credential that we want to keep. * * @param credsToRemove - Modified. * The set of credentials that will be removed. */ private static keepCred; /** * Remove all credential properties from the supplied session except for the * creds related to the session type specified within the sessCfg argument. * * @param sessCfg - Modified. * Authentication credentials are removed from this session configuration. * * @throws {ImperativeError} * If an invalid combination of session type and authTypeToRequestToken is encountered. */ private static removeExtraCredsFromSess; } //# sourceMappingURL=AuthOrder.d.ts.map