Engineering Blog

                            

Authenticating with ZOCli: Fast, Secure, Reliable Access

Overview

Authentication is a crucial aspect of securely accessing and managing cloud services. In the 01Cloud ecosystem, authentication through the Command Line Interface (CLI) ensures that only authorized users can perform tasks. The auth command facilitates the authentication process, allowing users to seamlessly log in and manage their sessions within 01Cloud.

This command supports various authentication methods, including Single Sign-On (SSO), access tokens, and basic credentials. Upon execution, the zocli CLI tool communicates with the 01Cloud server to verify user credentials and establish a secure session. The server logs this session, enabling users to review authentication details via the web UI.

To access the help menu for authentication commands, execute the following:

zocli auth –help

Login Methods

Authentication in the 01Cloud CLI offers multiple login methods to accommodate different security and usability requirements. Users can choose from the following options:

Single Sign-On (SSO) Authentication

Single Sign-On (SSO) is the recommended authentication method in 01Cloud. It provides a seamless and secure login experience, ensuring that credentials remain confidential and protected from unauthorized access.

To initiate the SSO login process, use the following command:

zocli auth login [-s || –sso]
zocli auth login

Once executed, the CLI will display an option to proceed with SSO authentication via a web browser. Users can navigate through the available options using the UP/DOWN arrow keys or filter results by typing relevant characters.

CLI-Generated Token

Upon selecting SSO authentication, the CLI communicates with the 01Cloud server to generate a new, time-sensitive token. This token must be used within five minutes to complete the login process. The CLI will print the SSO token on the console, similar to the example below:

Login using the browser using a dynamically generated code.
! First copy your one-time code: 111111
Press Enter to open https://console.01cloud.io/login/sso in your browser…

Logging in via Browser

Users can either click the provided link, manually copy and paste it into a web browser, or press ENTER to allow the CLI to open the browser automatically. After logging into the 01Cloud account, users will be prompted to enter the one-time code displayed on the terminal.

Once the correct code is entered, the CLI will retrieve the authentication credentials and complete the login process. This process typically takes around 5 seconds, during which the CLI continuously checks the authentication status.

To verify login status, use the following command:

zocli auth status

Access Token Authentication

For users who prefer token-based authentication, 01Cloud allows login using an Access Token. If a token has not been generated yet, follow the steps below:

Generating an Access Token

Users can create an access token via the 01Cloud web portal by navigating to PROFILE > ACCESS TOKEN. Here, they must enter a descriptive Note and set an expiration time for the token.

After clicking Generate, the system will create and display the new token. It is essential to copy and securely store this token, as it will not be visible again.

Logging in with an Access Token

To log in using the generated access token, execute the following command:

zocli auth login [-t || –token]
zocli auth login

Upon execution, the CLI will prompt the user to enter the previously generated token. Once entered, the CLI will communicate with the server to validate the token. If the authentication is successful, a confirmation message will be displayed:

✓ Logged in successfully as yourmail@mail.com

Exporting the Token to Environment Variables

Users can also authenticate using an exported environment variable. This method is useful for automating authentication in scripts and CI/CD pipelines.

To export the token, use the following command:

export CLI_WEBTOKEN=token

Then, log in using:

zocli auth login [-t || –token]

Basic Credentials Authentication

This method allows users to authenticate using their email and password. While functional, it is not recommended due to security concerns and may be removed in future updates.

To log in using basic credentials, execute:

zocli auth login [-b || –basic]

The CLI will prompt the user to enter their email and password. Upon successful validation, the following message will be displayed:

✓ Logged in successfully as yourmail@mail.com

Automating Basic Authentication

For users who prefer automatic login, credentials can be stored in environment variables. This enables seamless authentication during CLI execution.

To export credentials:

export CLI_EMAIL=yourEmail
export CLI_PASSWORD=yourPassword

Then, authenticate using:

zocli auth login [- || –basic]

Summary of Authentication Methods

  • SSO Authentication: Use zocli auth login -s for secure login via browser.
  • Access Token Authentication: Use zocli auth login -t to authenticate with a pre-generated token.
  • Basic Credentials Authentication: Use zocli auth login -b (not recommended) to log in with email and password.
  • General Login Command: Run zocli auth login to view all available options.
  • Help Menu: Execute zocli auth login –help to get detailed usage instructions.

Logging Out

To log out from the 01Cloud CLI, removing authentication credentials from the device, use the following command:

zocli auth logout

If the session should remain active on the server while logging out from the CLI, use the -d flag:

zocli auth logout -d

After successful logout, the CLI will confirm:

✓ Successfully Logged out.

Checking Authentication Status

To check whether the current authentication session is valid, run:

zocli auth status

If the token is valid, the CLI will display profile details and available quotas:

✓ Token is valid
✓ Fetched Profile

PROFILE
Name : yourName
Email : yourEmail@mail.com
Company : yourCompanyName

QUOTAS
Projects : totalNoOfProjects
Organizations : totalOrganizations

Conclusion

Authentication is the foundation of secure access within the 01Cloud ecosystem. The CLI provides multiple authentication methods to cater to different user preferences, ensuring both security and flexibility. By leveraging SSO, access tokens, or basic credentials, users can securely authenticate and manage their cloud resources with ease.

For detailed help, always refer to:

zocli auth –help

Join the 01Cloud Community!

Do you need guidance, have questions, or want to collaborate with fellow cloud professionals? Join the 01Cloud Community on Discord and engage with developers, DevOps engineers, and cloud enthusiasts. Share insights, discuss best practices, and get expert advice.

Embrace the power of automation and efficiency with ZOCLI. Take control of your 01Cloud environment today!

Follow us for more Updates

Previous Post