Authentication
PiVirt supports flexible, zero-trust authentication mechanisms tailored for interactive CLI users, automated CI/CD runners, and internal service-to-service communications.
Authentication Methods
Section titled “Authentication Methods”1. OIDC (OpenID Connect)
Section titled “1. OIDC (OpenID Connect)”For external clients (pvcli, Web UIs).
Configuration:
# agent configauth: oidc: issuer_url: "https://auth.pilab.hu/realms/pivirt" client_id: "pivirt-agent" # JWKS auto-discovered from issuer_url/.well-known/jwks.jsonLogin with pvcli:
# Interactive login (opens browser)pvcli auth login --oidc
# Device code flow (headless)pvcli auth login --oidc --device-code
# Check token statuspvcli auth status
# Refresh tokenpvcli auth refreshSupported Providers:
- Keycloak
- Dex
- Auth0
- Azure AD
- Google Workspace
2. mTLS (Mutual TLS)
Section titled “2. mTLS (Mutual TLS)”For service-to-service authentication.
Configuration:
# agent configserver: connectrpc: tls: cert_file: "/etc/pivirt-agent/tls/server.crt" key_file: "/etc/pivirt-agent/tls/server.key" ca_file: "/etc/pivirt-agent/tls/ca.crt" client_ca_file: "/etc/pivirt-agent/tls/ca.crt"pvcli mTLS:
# Generate client certificatepvcli cert generate --cn "admin@pilab.hu" --org "PiLab"
# Configure context with certificatespvcli config set-context production \ --ca-file /path/to/ca.crt \ --cert-file /path/to/client.crt \ --key-file /path/to/client.key3. PiTrust PKI & Zero-Trust mTLS
Section titled “3. PiTrust PKI & Zero-Trust mTLS”For service-to-service zero-trust identity and automated certificate management.
Configuration:
# agent configtls: enabled: true ca_file: "/etc/pivirt/certs/ca-chain.pem" cert_file: "/etc/pivirt/certs/agent-client.crt" key_file: "/etc/pivirt/certs/agent-client.key" verify_peer: true require_client_cert: trueAutomated Kubernetes Management:
- Declarative
ManagedCertificateCRDs managed by PiTrust Operator - Automatic 30-day pre-expiry renewal into Kubernetes Secrets
- Zero external ACME/DNS challenge requirement (air-gapped ready)
4. API Keys
Section titled “4. API Keys”For service accounts and automation.
Create API Key:
pvcli auth apikey create \ --name "ci-pipeline" \ --role "operator" \ --namespace "production" \ --ttl 30dUse API Key:
export PIVIRT_API_KEY="pivirt_apikey_..."pvcli vm listToken Management
Section titled “Token Management”JWT Tokens
Section titled “JWT Tokens”# Get token infopvcli auth token inspect
# Decode tokenpvcli auth token decode
# Revoke tokenpvcli auth token revoke --token-id <id>Service Account Tokens
Section titled “Service Account Tokens”apiVersion: pivirt.pilab.hu/v1kind: ServiceAccountmetadata: name: ci-pipeline namespace: productionspec: roles: - "operator" token_ttl: "30d"Multi-Factor Authentication
Section titled “Multi-Factor Authentication”TOTP (Time-based One-Time Password)
Section titled “TOTP (Time-based One-Time Password)”# Enable MFA for userpvcli auth mfa enable --user admin@pilab.hu --method totp
# Verify MFApvcli auth login --mfaHardware Keys (FIDO2/WebAuthn)
Section titled “Hardware Keys (FIDO2/WebAuthn)”# Register hardware keypvcli auth mfa enable --user admin@pilab.hu --method webauthn
# Login with hardware keypvcli auth login --mfaSession Management
Section titled “Session Management”Session Configuration
Section titled “Session Configuration”# agent configauth: session: max_age: "24h" idle_timeout: "1h" refresh_interval: "5m"Active Sessions
Section titled “Active Sessions”# List active sessionspvcli auth session list
# Revoke sessionpvcli auth session revoke --session-id <id>
# Revoke all sessionspvcli auth session revoke --allTroubleshooting
Section titled “Troubleshooting”Authentication Failures
Section titled “Authentication Failures”# Check token validitypvcli auth status
# Verify OIDC configurationcat /etc/pivirt-agent/config.yaml | grep -A5 oidc
# Check certificate validityopenssl x509 -in ~/.config/pvcli/client.crt -text -noout | grep "Not After"
# Test OIDC endpointcurl https://auth.pilab.hu/realms/pivirt/.well-known/openid-configurationCommon Issues
Section titled “Common Issues”| Issue | Resolution |
|---|---|
| Token expired | Refresh token: pvcli auth refresh |
| Certificate expired | Regenerate certificate: pitrust issue-mtls-client or check Operator |
| OIDC provider unreachable | Check network, verify issuer_url |
| mTLS handshake failed | Verify CA trust chain with PiRootR1.pem / PiCA.pem |