Authentication CLI

Command-line tool that provides a complete authentication workflow including user registration, login, Multi-Factor Authentication (MFA), and API key management.

Complete How-To Guide

Features

  • User Registration - Create new accounts with email verification

  • Login & Authentication - Secure login with access/refresh tokens

  • Multi-Factor Authentication (MFA) - Optional two-factor authentication for enhanced security

  • Account Verification - Verify email addresses with verification codes

  • API Key Management - Create and revoke API keys for programmatic access

  • Token Persistence - Save tokens securely for seamless authentication

  • Token Refresh - Automatically refresh expired access tokens

  • User Information - Display current user details with whoami

Prerequisites

  • Go 1.19 or higher (for building from source)

  • Valid email address for registration

  • Internet connection

  • Operating System: Linux, macOS, or Windows

Installation

Option 1: Download Pre-built Binary

Download the latest release for your platform from the releases pagearrow-up-right.

Option 2: Install from Source

Option 3: Using Go Install

Getting Started

Basic Command Structure

Global Flags

  • --base-url string: Override the API base URL (default: https://uat.koneksi.co.krarrow-up-right)

  • --config string: Config file path (default: ~/.koneksi-auth/config.yaml)

  • -o, --output string: Output format (text, json)

  • -h, --help: Show help information

View Available Commands

User Registration

Step 1: Create a New Account

Register a new user account with required information:

Optional fields:

  • --middle-name: Middle name

  • --suffix: Name suffix (Jr., Sr., etc.)

Example Output

Account Verification

After registration, you must verify your email address before creating API keys.

Step 1: Login to Get Access Token

Save the access token from the output.

Step 2: Verify Your Account

Check your email for the 6-digit verification code, then:

Example Output

Login and Authentication

Standard Login

Save Tokens to Config

Use the --save flag to store tokens in your config file:

Login Output (Without MFA)

Multi-Factor Authentication (MFA)

MFA adds an extra layer of security to your account using Time-based One-Time Passwords (TOTP).

Setting Up MFA

Step 1: Generate MFA Secret

Output:

Step 2: Add to Authenticator App

  1. Open your authenticator app (Google Authenticator, Authy, 1Password, etc.)

  2. Add a new account

  3. Either:

    • Scan the QR code from the provided URL

    • Manually enter the secret key

Step 3: Enable MFA

Get the 6-digit code from your authenticator app and enable MFA:

Output:

Login with MFA

When MFA is enabled, login becomes a two-step process:

Step 1: Initial Login

Output:

Step 2: Complete Login with OTP

Get the current 6-digit code from your authenticator app:

Output:

Disabling MFA

To disable MFA, you need your account password:

Output:

API Key Management

API keys (service accounts) are used for programmatic access to Koneksi services.

Create an API Key

Output:

List Your API Keys

Revoke an API Key

Output:

Configuration

Configuration File

The CLI uses a YAML configuration file located at ~/.koneksi-auth/config.yaml:

Environment Variables

You can also use environment variables:

Priority Order

  1. Command-line flags (highest priority)

  2. Environment variables

  3. Configuration file

  4. Default values

Advanced Usage

Using Different Environments

Development Environment

Production Environment

Create a separate config file:

JSON Output for Scripting

Use -o json for machine-readable output:

Refresh Expired Tokens

Check Current User

Troubleshooting

Common Issues

1. "Authentication token required" Error

Solution: Provide the access token using one of these methods:

  • Command flag: -t "your-token"

  • Environment variable: export KONEKSI_AUTH_TOKEN="your-token"

  • Config file with saved token

2. "Account not verified" Error

Solution: Complete email verification:

3. MFA Code Invalid

Possible causes:

  • Time sync issue: Ensure your device time is accurate

  • Wrong code: Make sure you're using the current 6-digit code

  • Wrong account: Verify you're using the correct authenticator entry

4. Token Expired

Solution: Use the refresh token to get a new access token:

Debug Mode

For verbose output, set the log level:

Getting Help

  1. Command help: koneksi-auth [command] --help

  2. GitHub Issues: https://github.com/koneksi/auth-cli/issues

  3. Documentation: https://docs.koneksi.co.kr

Security Best Practices

  1. Never share your tokens or API credentials

  2. Use environment variables in CI/CD pipelines instead of hardcoding credentials

  3. Enable MFA for enhanced account security

  4. Rotate API keys regularly

  5. Store config files with restricted permissions: chmod 600 ~/.koneksi-auth/config.yaml

  6. Use separate API keys for different applications/environments

  7. Revoke unused API keys promptly

Complete Workflow Example

Here's a complete example from registration to API usage:

Next Steps

After setting up authentication:

  1. Use your API keys with other Koneksi services

  2. Integrate with koneksi-backup for data backup

  3. Set up automated workflows with your CI/CD pipeline

  4. Monitor API key usage through the Koneksi dashboard


Additional Resources

Last updated