Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle new APIML unique cookie identifier #1734

Merged
merged 35 commits into from
Aug 4, 2023
Merged

Handle new APIML unique cookie identifier #1734

merged 35 commits into from
Aug 4, 2023

Conversation

zFernand0
Copy link
Member

@zFernand0 zFernand0 commented Jun 26, 2023

What It Does

How to Test

Note: you may need to build the APIML (https://github.com/zowe/api-layer) locally in order to configure it to use unique cookie identifiers

Commands to try:

  • zowe auth login apiml
  • zowe auth logout apiml
  • zowe config secure
  • zowe config auto-init

Scenarios from Imperative:

  • prevented multiple logout operations from failing due to not having a token available
    • Scenarios:
      • have an expired token in your vault, or
      • save a dummy value for the tokenValue property, or
      • have an empty string as your token
    • Before:
       λ zowe auth logout apiml
       Enter the host name of your service: sys1.com
       Enter the port number for your service: 10010
       Command Error:
       This operation requires authentication.
      
       z/OSMF REST API Error:
       Rest API failure with HTTP(S) status 401
       messages:
         -
           messageType:    ERROR
           messageNumber:  ZWEAT100E
           messageContent: Token is expired for URL '/api/v1/gateway/auth/logout'
           messageKey:     org.zowe.apiml.security.expiredToken
      
       Host:      sys1.com
       Port:      10010
       Base Path:
       Resource:  /api/v1/gateway/auth/logout
       Request:   POST
       Headers:   undefined
       Payload:   POST
      
       Error Details:
       Token is not valid or expired.
      
       For CLI usage, see `zowe auth login apiml --help`
      
    • After:
      # zdev auth logout apiml
      Logout successful. The authentication token has been revoked and removed from your 'base_real' base profile
      
  • added support for multiple token authentication processes in a single config secure command
    • Scenarios:
      • with a config file that hase more than one base profile with tokenValue in the secure array
    • Before:
      # zdev config secure --gc
      Enter profiles.base_real.properties.tokenValue - blank to skip: 
      Enter profiles.base_mock.properties.tokenValue - blank to skip:
      
    • After:
      # zdev config secure --gc
      Processing secure properties for profile: base_mock
      Logging in to your API Mediation Layer
      Enter the user name for your API Mediation Layer (will be hidden): 
      Enter the password for your API Mediation Layer (will be hidden): 
      Processing secure properties for profile: base_real
      Logging in to your API Mediation Layer
      Enter the user name for your API Mediation Layer (will be hidden): 
      Enter the password for your API Mediation Layer (will be hidden): 
      
    • added an entry to the console.log to inform which profile credentials are being prompted for
      • Notice the Processing secure properties for profile: <profile_name> above
  • prevented auto-init from performing two login operations on a single command
    • Scenarios:
      • perform a zowe auth login apiml operation and then remove the token from the vaullt
    • Before:
      • 1st login when prompted for the tokenValue (which will ask for user:password to login)
      • 2nd login in the doAutoInit functionality since the user:password are still provided in the ISession
    • After:
      • Only one login operation

Reverted scenario:

  • allowed logout operation to remove token type and/or token value when either is not specified in the config file
    • NOTE: this scenario conflicts with the ability to logout a token different from the one stored in the vault
    • Scenarios:
      • with a config that's missing either tokenType or tokenValue
    • Before:
      λ zowe auth logout apiml
      Enter the host name of your service: sys1.com
      Enter the port number for your service: 10010
      Command Error:
      This operation requires authentication.
      
      z/OSMF REST API Error:
      Rest API failure with HTTP(S) status 401
      messages:
        -
          messageType:    ERROR
          messageNumber:  ZWEAT100E
          messageContent: Token is expired for URL '/api/v1/gateway/auth/logout'
          messageKey:     org.zowe.apiml.security.query.tokenNotProvided
      
      Host:      sys1.com
      Port:      10010
      Base Path:
      Resource:  /api/v1/gateway/auth/logout
      Request:   POST
      Headers:   undefined
      Payload:   POST
      
      Error Details:
      Token is not valid or expired.
      
      For CLI usage, see `zowe auth login apiml --help`
      
    • After:
      # zdev auth logout apiml
      Logout successful. The authentication token has been revoked.
      

Review Checklist
I certify that I have:

Additional Comments

Copy link
Member

@gejohnston gejohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member

@awharn awharn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small observation

packages/cli/src/config/auto-init/ApimlAutoInitHandler.ts Outdated Show resolved Hide resolved
Signed-off-by: zFernand0 <[email protected]>
@zFernand0 zFernand0 linked an issue Jul 28, 2023 that may be closed by this pull request
@zFernand0 zFernand0 linked an issue Aug 1, 2023 that may be closed by this pull request
Copy link
Member

@t1m0thyj t1m0thyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @zFernand0!

Copy link
Member

@gejohnston gejohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @zFernand0 😃

@sonarcloud
Copy link

sonarcloud bot commented Aug 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

98.6% 98.6% Coverage
0.0% 0.0% Duplication

@traeok traeok merged commit bc9b85c into master Aug 4, 2023
20 checks passed
@traeok traeok deleted the imp-979 branch August 4, 2023 18:41
@traeok traeok added the release-minor Indicates a minor feature has been added label Aug 4, 2023
@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Release succeeded for the master branch. 🎉

The following packages have been published:

Powered by Octorelease 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-minor Indicates a minor feature has been added released
Projects
None yet
5 participants