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.

### Hierarchy

- AuthOrder

## Index

### Properties

- ARRAY_OF_CREDS
- SESS_CERT_KEY_NAME
- SESS_CERT_NAME

### Methods

- addCredsToSession
- authArrayToCfgVal
- authCfgValToArray
- cacheAuthOrder
- cacheCred
- cacheCredsAndAuthOrder
- cacheDefaultAuthOrder
- chooseDefaultAuthOrder
- clearAuthCache
- findOrCreateAuthCache
- formNewAuthOrderArray
- getAuthOrder
- getPropNmFor
- keepCred
- makingRequestForToken
- putNewAuthsFirstInSess
- putNewAuthsFirstOnDisk
- putTopAuthInSession
- removeExtraCredsFromSess
- removeRequestForToken

## Properties

### Static Private Readonly ARRAY_OF_CREDS

ARRAY_OF_CREDS: string[] = ["user", "password", "base64EncodedAuth", "tokenType", "tokenValue",AuthOrder.SESS_CERT_NAME, AuthOrder.SESS_CERT_KEY_NAME]

- Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:70

### Static Private Readonly SESS_CERT_KEY_NAME

SESS_CERT_KEY_NAME: "certKey" = "certKey"

- Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:69

### Static Private Readonly SESS_CERT_NAME

SESS_CERT_NAME: "cert" = "cert"

- Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:68

## Methods

### Static addCredsToSession

- addCredsToSession<SessCfgType>(sessCfg: SessCfgType, cmdArgs?: ICommandArguments): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:94

  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.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. A session configuration object into which we place cached creds and the selected creds.

  - ##### Default value cmdArgs: ICommandArguments = { "$0": "NameNotUsed", "_": [] }

    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.

  #### Returns void

### Static Private authArrayToCfgVal

- authArrayToCfgVal(authTypesArray: SessConstants.AUTH_TYPE_CHOICES[]): string

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:639

  Convert an AUTH_TYPE_CHOICES array to a string that is an appropriate value for the "authOrder" configuration property.

  #### Parameters

  - ##### authTypesArray: SessConstants.AUTH_TYPE_CHOICES[]

    input. An array of auth types.

  #### Returns string

  A string containing a valid value for the authOrder configuration property.

### Static Private authCfgValToArray

- authCfgValToArray(authCfgVal: string): SessConstants.AUTH_TYPE_CHOICES[]

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:653

  Convert a string that is an appropriate value for the "authOrder" configuration property into an array of AUTH_TYPE_CHOICES.

  #### Parameters

  - ##### authCfgVal: string

    input. An authOrder property value.

  #### Returns SessConstants.AUTH_TYPE_CHOICES[]

  An array of AUTH_TYPE_CHOICES.

### Static Private cacheAuthOrder

- cacheAuthOrder<SessCfgType>(sessCfg: SessCfgType, cmdArgs: ICommandArguments): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:706

  Cache the authOrder property from the supplied cmdArgs. If no authOrder exists in cmdArgs, a default authOrder is created and cached.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. A session configuration object into which we store the auth cache.

  - ##### cmdArgs: ICommandArguments

    Input. The set of arguments that the calling function is using.

  #### Returns void

### Static Private cacheCred

- cacheCred<SessCfgType>(sessCredName: string, sessCfg: SessCfgType, cmdArgs: ICommandArguments): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:775

  Cache the named credential into our cache of available credentials.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCredName: string

    Input. The name of a cred to be cached in a session.

  - ##### sessCfg: SessCfgType

    Modified. A session configuration object.

  - ##### cmdArgs: ICommandArguments

    Input. The set of arguments with which the calling function is operating.

  #### Returns void

### Static Private cacheCredsAndAuthOrder

- cacheCredsAndAuthOrder<SessCfgType>(sessCfg: SessCfgType, cmdArgs?: ICommandArguments): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:678

  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.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. A session configuration object to which we place the cached creds.

  - ##### Default value cmdArgs: ICommandArguments = { "$0": "NameNotUsed", "_": [] }

    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.

  #### Returns void

### Static cacheDefaultAuthOrder

- cacheDefaultAuthOrder<SessCfgType>(sessCfg: SessCfgType, topDefaultAuth: typeof AUTH_TYPE_BASIC | typeof AUTH_TYPE_TOKEN): boolean

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:130

  Cache the default authentication order to be used when the user has NOT specified an order. No action is performed if the end-user HAS defined an authentication order in their zowe client configuration.

  For historical reason, we have 2 default orders. Thus, the caller can specify which of 2 creds to use as the top cred in the authentication order: SessConstants.AUTH_TYPE_BASIC or SessConstants.AUTH_TYPE_TOKEN

  internal
    - Cannot be used outside of the imperative package

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. A session configuration object into which we place the default order.

  - ##### topDefaultAuth: typeof AUTH_TYPE_BASIC | typeof AUTH_TYPE_TOKEN

    Input. The authentication type that will be used first.

  #### Returns boolean

  True when the default order was cached. False when the user supplied an order, because you cannot override the user-supplied order with any default.

### Static Private chooseDefaultAuthOrder

- chooseDefaultAuthOrder<SessCfgType>(sessCfg: SessCfgType): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:802

  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.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. A session configuration object.

  #### Returns void

### Static clearAuthCache

- clearAuthCache<SessCfgType>(sessCfg: SessCfgType): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:179

  Clears the authentication cache.

  To get the right creds and auth order in your session after calling this function you must once again call the appropriate combination of: AuthOrder.addCredsToSession AuthOrder.cacheDefaultAuthOrder AuthOrder.putTopAuthInSession

  internal
    - Cannot be used outside of the imperative package

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

  #### Returns void

### Static Private findOrCreateAuthCache

- findOrCreateAuthCache<SessCfgType>(sessCfg: SessCfgType): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:824

  Find the auth cache in the session config. If there is no cache recorded in the session config, create a new auth cache entry.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Input. A session configuration object into which we record any newly created cache.

  #### Returns void

### Static Private formNewAuthOrderArray

- formNewAuthOrderArray(existingAuths: SessConstants.AUTH_TYPE_CHOICES[], newFirstAuths: SessConstants.AUTH_TYPE_CHOICES[], newAuthsOpts?: INewFirstAuthsOpts): SessConstants.AUTH_TYPE_CHOICES[]

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:599

  Form a new auth type array from an existing array and a second array whose members should come first in the new array. Duplicates are removed from the resulting authOrder array. Any auth types from the existing array remain later in the array, unless newAuthsOpts.onlyTheseAuths is true.

  #### Parameters

  - ##### existingAuths: SessConstants.AUTH_TYPE_CHOICES[]

    input. An existing array of auth types.

  - ##### newFirstAuths: SessConstants.AUTH_TYPE_CHOICES[]

    input. An array of one or more auth types to be placed at the front of the the existing array of auth types.

  - ##### Default value newAuthsOpts: INewFirstAuthsOpts = {onlyTheseAuths: false}

    input. Options that control some replacement choices.

  #### Returns SessConstants.AUTH_TYPE_CHOICES[]

  A new array of AUTH_TYPE_CHOICES.

### Static getAuthOrder

- getAuthOrder<SessCfgType>(sessCfg: SessCfgType): SessConstants.AUTH_TYPE_CHOICES[]

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:200

  Returns the cached authentication order. If no auth order exists, we create and return a default auth order.

  internal
    - Cannot be used outside of the imperative package

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. The session config from which we retrieve the cached auth order. When no auth order exists in the sessCfg, a default auth order is stored in the sessCfg, before returning that newly created value.

  #### Returns SessConstants.AUTH_TYPE_CHOICES[]

  The cached authentication order.

### Static getPropNmFor

- getPropNmFor(propName: string, desiredUse: PropUse): string

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:228

  Get the correct property name for use in either a session or in a config file. Currently only certificate property names are different between the two.

  internal
    - Cannot be used outside of the imperative package

  #### Parameters

  - ##### propName: string

    input. The name of a property for which we must select the correct name to.

  - ##### desiredUse: PropUse

    input. Specifies where property is to be used.

  #### Returns string

  The cached authentication order.

### Static Private keepCred

- keepCred(credToKeep: string, credsToRemove: Set<string>): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:857

  Keep the specified credential by deleting it from the set of credentials to remove.

  #### Parameters

  - ##### credToKeep: string

    Input. The credential that we want to keep.

  - ##### credsToRemove: Set<string>

    Modified. The set of credentials that will be removed.

  #### Returns void

### Static makingRequestForToken

- makingRequestForToken<SessCfgType>(sessCfg: SessCfgType): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:257

  Record that the session is being used to make a request for a token (ie logging into APIML).

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. The session config into which we record that we are requesting a token.

  #### Returns void

### Static putNewAuthsFirstInSess

- putNewAuthsFirstInSess<SessCfgType>(sessCfg: SessCfgType, newFirstAuths: SessConstants.AUTH_TYPE_CHOICES[], newAuthsOpts?: INewFirstAuthsOpts): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:455

  Put the specified array of auth types first in the authOrder for the specified session. Duplicates are removed from the resulting authOrder array. Any existing auth types remain later in the array, unless newAuthsOpts.onlyTheseAuths is true.

  Calling apps should NOT use this function to impose a hard-coded authentication order for the session. Users control that decision. Apps should only call this function if the app is implementing a directive from the user which implies that the authOrder should be changed. An example is when a user logs into APIML. The implication is that the user wants to use a token, and that tokens should be at the front of the authentication order.

  throws

    {ImperativeError} If sessCfg is null or undefined.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. The session config into which we place the modified array of auth types.

  - ##### newFirstAuths: SessConstants.AUTH_TYPE_CHOICES[]

    input. An array of one or more auth types to be placed at the front of the the existing array of auth types.

  - ##### Default value newAuthsOpts: INewFirstAuthsOpts = {onlyTheseAuths: false}

    input. Options that control some replacement choices.

  #### Returns void

### Static putNewAuthsFirstOnDisk

- putNewAuthsFirstOnDisk(profileName: string, newFirstAuths: SessConstants.AUTH_TYPE_CHOICES[], newAuthsOnDiskOpts?: INewFirstAuthsOnDiskOpts): Promise<void>

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:506

  Put the specified array of auth types first in the authOrder property for the specified profile and save it to the client config file on disk. A new authOrder property will be created if needed. Duplicates from any existing authOrder are removed from the resulting authOrder. Any existing auth types remain later in the property value, unless newAuthsOpts.onlyTheseAuths is true.

  Calling apps should NOT use this function to impose a hard-coded authentication order for a profile. Users control that decision. Apps should only call this function if the app is implementing a directive from the user which implies that the authOrder should be changed. An example is when a user logs into APIML. The implication is that the user wants to use a token, and that tokens should be at the front of the authentication order.

  throws

    {ImperativeError} Any detected error is in the 'message' of the ImperativeError.

  #### Parameters

  - ##### profileName: string

    input. The name of the profile into which the authOrder property will be placed.

  - ##### newFirstAuths: SessConstants.AUTH_TYPE_CHOICES[]

    input. An array of one or more auth types to be placed at the front of the the existing array of auth types.

  - ##### Default value newAuthsOnDiskOpts: INewFirstAuthsOnDiskOpts = {onlyTheseAuths: false,clientConfig: ImperativeConfig.instance.config}

  #### Returns Promise<void>

### Static putTopAuthInSession

- putTopAuthInSession<SessCfgType>(sessCfg: SessCfgType): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:302

  Find the highest auth type (according to the authOrder) that exists in availableCreds within the supplied session config. Then place the credentials associated with that auth type into the top-level of the session config. Finally, remove credentials for all other auth types from the top-level of session config.

  internal
    - Cannot be used outside of the imperative package
  throws

    {ImperativeError} If an invalid auth type is encountered.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. Authentication properties are added to and removed from this session configuration, which can already have properties in this object when passed to this function.

  #### Returns void

### Static Private removeExtraCredsFromSess

- removeExtraCredsFromSess<SessCfgType>(sessCfg: SessCfgType): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:872

  Remove all credential properties from the supplied session except for the creds related to the session type specified within the sessCfg argument.

  throws

    {ImperativeError} If an invalid combination of session type and authTypeToRequestToken is encountered.

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. Authentication credentials are removed from this session configuration.

  #### Returns void

### Static removeRequestForToken

- removeRequestForToken<SessCfgType>(sessCfg: SessCfgType): void

- - Defined in @zowe/imperative/src/rest/src/session/AuthOrder.ts:277

  Remove any request-for-token from the session config.

  internal
    - Cannot be used outside of the imperative package

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

    Modified. The session config from which we remove a request-for-token.

  #### Returns void

Generated using TypeDoc