Overview
Theauthforms command returns structured form definitions that the host renders as connection creation UI. Plugins can define multiple authentication methods (e.g., “Basic” and “DSN”).
Command Invocation
AuthFormsResponse object
Timeout: 30 seconds
Required: Yes - plugins without this command fall back to a single DSN text input
Response Structure
Map of form definitions, keyed by form identifier (e.g.,
"basic", "dsn"). Each form contains:AuthForm Fields
Machine identifier for the form (e.g.,
"basic", "dsn")Human-readable form name displayed in UI tabs (e.g.,
"Basic", "DSN")Array of form field definitions
AuthField Properties
Example Implementation
Fromplugins/mysql/main.go:
Response Format (stdout)
Form Submission Flow
- Host calls
authformsand renders tabs for each form - User selects a tab and fills in the fields
- On submit, host serializes form values as JSON:
- Host stores this JSON in the connection’s
credential_blobfield - When executing queries, the plugin receives this blob in
connection["credential_blob"]
Best Practices
- Always provide a fallback DSN form for advanced users
- Use
PASSWORDtype for sensitive fields to enable masking - Set sensible defaults in the
valuefield for common parameters - Use
SELECTfields for predefined options (e.g., TLS modes) - Mark essential fields as
required: true - Use
FILE_PATHfor certificate or key file selectors
Error Handling
- If the command fails, write error details to stderr and exit with non-zero status code
- Plugins that fail
authformsfall back to a single generic credential text input - The host does not validate field values - validation should occur during
execortest-connection