Skip to content

Commit c0303d1

Browse files
authored
Document configurable TOTP credential settings (#660)
* Document configurable TOTP credentials and vault limits * Make credential TOTP guidance scannable * Show typed TOTP settings in SDK examples
1 parent bdcf2e5 commit c0303d1

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎auth/credentials.mdx‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ _ = login
167167

168168
### 2FA with TOTP
169169

170-
For sites with authenticator app 2FA, include `totp_secret` so Kernel can generate a fresh code during automatic login and reauthentication:
170+
For sites with authenticator app 2FA, include `totp_secret` so KERNEL can generate a fresh code during automatic login and reauthentication. Supply a base32 secret of 16–128 characters or an `otpauth://totp/` provisioning URI. The default is SHA1, 6 digits, and a 30-second period. If the authenticator uses different settings, provide `totp_algorithm` (`SHA1`, `SHA256`, or `SHA512`), `totp_digits` (6–9), and `totp_period` (15–300 seconds):
171171

172172
<CodeGroup>
173173
```typescript TypeScript
@@ -178,7 +178,10 @@ const credential = await kernel.credentials.create({
178178
username: 'my-username',
179179
password: 'my-password',
180180
},
181-
totp_secret: 'JBSWY3DPEHPK3PXP', // From authenticator app setup
181+
totp_secret: 'JBSWY3DPEHPK3PXP',
182+
totp_algorithm: 'SHA512',
183+
totp_digits: 8,
184+
totp_period: 60,
182185
});
183186
```
184187

@@ -190,7 +193,10 @@ credential = await kernel.credentials.create(
190193
"username": "my-username",
191194
"password": "my-password",
192195
},
193-
totp_secret="JBSWY3DPEHPK3PXP", # From authenticator app setup
196+
totp_secret="JBSWY3DPEHPK3PXP",
197+
totp_algorithm="SHA512",
198+
totp_digits=8,
199+
totp_period=60,
194200
)
195201
```
196202

@@ -203,7 +209,10 @@ credential, err := client.Credentials.New(ctx, kernel.CredentialNewParams{
203209
"username": "my-username",
204210
"password": "my-password",
205211
},
206-
TotpSecret: kernel.String("JBSWY3DPEHPK3PXP"), // From authenticator app setup
212+
TotpSecret: kernel.String("JBSWY3DPEHPK3PXP"),
213+
TotpAlgorithm: kernel.CreateCredentialRequestTotpAlgorithmSha512,
214+
TotpDigits: kernel.Int(8),
215+
TotpPeriod: kernel.Int(60),
207216
},
208217
})
209218
if err != nil {
@@ -213,6 +222,13 @@ _ = credential
213222
```
214223
</CodeGroup>
215224

225+
The examples use typed fields available in TypeScript, Python, and Go SDK v0.116.0 or later. You can also pass an `otpauth://totp/` provisioning URI as `totp_secret`.
226+
227+
- URI parameters override explicit settings. If a parameter is missing, the API uses its explicit field, then the default.
228+
- Replacing a URI resets omitted settings to defaults. Rotating a raw secret preserves stored settings unless you send new values.
229+
- The API stores only the normalized seed, never the URI label or issuer.
230+
- A code's length follows `totp_digits`; don't assume six digits when reading `totp_code` or calling `totpCode()`.
231+
216232
### SSO / OAuth
217233

218234
For sites with "Sign in with Google/GitHub/Microsoft", set `sso_provider` so Kernel can select the matching SSO route. Automatic completion depends on the provider's login requirements.

‎integrations/1password.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ If multiple items match a domain, the first match is used. Organize your vaults
142142

143143
## TOTP Support
144144

145-
If your 1Password item has a one-time password (TOTP) field configured, Kernel can generate fresh codes for automatic login and reauthentication. No additional setup is needed.
145+
If your 1Password item has a one-time password (TOTP) field configured, KERNEL uses its `otpauth://` secret, algorithm (SHA1, SHA256, or SHA512), digit count (6–9), and period (15–300 seconds) to generate fresh codes for automatic login and reauthentication. Missing settings default to SHA1, 6 digits, and 30 seconds. An unsupported setting makes the field unavailable instead of generating an incorrect fallback code.
146146

147147
## Supported Login Types
148148

‎reference/cli/managed-auth.mdx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ Create a new credential.
142142
| `--name <name>` | Unique name for the credential (required). |
143143
| `--domain <domain>` | Target domain this credential is for (required). |
144144
| `--value <name=value>` | Field name/value pair (repeatable, e.g. `--value username=myuser --value password=mypass`). |
145-
| `--totp-secret <secret>` | Base32-encoded TOTP secret for 2FA. |
145+
| `--totp-secret <secret>` | Base32 TOTP secret (16–128 characters) or `otpauth://` provisioning URI. |
146+
| `--totp-algorithm <name>` | `SHA1` (default), `SHA256`, or `SHA512`. URI parameters override explicit settings. |
147+
| `--totp-digits <n>` | Code length, 6–9 digits (default 6). |
148+
| `--totp-period <seconds>` | Rotation period, 15–300 seconds (default 30). |
146149
| `--sso-provider <provider>` | SSO provider (e.g. `google`, `github`, `microsoft`). |
147150
| `--output json`, `-o json` | Output raw JSON object. |
148151

@@ -170,7 +173,10 @@ Update a credential.
170173
|------|-------------|
171174
| `--name <name>` | New name for the credential. |
172175
| `--value <name=value>` | Field name/value pair to update (repeatable). |
173-
| `--totp-secret <secret>` | Base32-encoded TOTP secret (set to an empty string to remove). |
176+
| `--totp-secret <secret>` | Replacement base32 secret (16–128 characters) or `otpauth://` URI. Raw secret rotation retains stored settings when flags are omitted; a URI uses its own settings or defaults. |
177+
| `--totp-algorithm <name>` | `SHA1`, `SHA256`, or `SHA512`; requires `--totp-secret`. |
178+
| `--totp-digits <n>` | Code length, 6–9 digits; requires `--totp-secret`. |
179+
| `--totp-period <seconds>` | Rotation period, 15–300 seconds; requires `--totp-secret`. |
174180
| `--sso-provider <provider>` | SSO provider (set to an empty string to remove). |
175181
| `--output json`, `-o json` | Output raw JSON object. |
176182

‎vaults/credentials.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ set `provider: "kernel"` so KERNEL stores the values and hosts collection. the a
103103

104104
password and totp fields must be sensitive. usernames and email addresses can also remain sensitive; `fill` works either way. fields marked `sensitive: false` return their stored values in item responses.
105105

106+
Vault `totp` fields currently generate SHA1, six-digit codes every 30 seconds. Configurable TOTP settings on stored managed-auth credentials do **not** apply to vault items. For a non-default algorithm, digit count, or period, don't use a vault `totp` field for fill until that API supports those settings.
107+
106108
`fields` is an ordered array. define fields in the same top-to-bottom order as the website; collection forms preserve it exactly. `name` remains authoritative for `state.fields`, updates, and `fill`. `label` only changes display text and is returned as non-secret metadata. labels must be nonempty, trimmed, single-line display text of at most 128 utf-8 bytes.
107109

108110
an item accepts 1–32 named fields. field names must start with an ascii letter, contain only ascii letters, numbers, and underscores, and be at most 64 characters. `email` values must be bare valid addresses such as `user@example.com`; use `text` for usernames that aren't valid email addresses. initial values must be nonempty strings and fit within 16 kib of utf-8 data each; `null` and empty strings aren't accepted on creation.

0 commit comments

Comments
 (0)