Skip to content

Commit be6d98a

Browse files
committed
feat(monolith): Get started using tokens
1 parent 21ad484 commit be6d98a

File tree

1 file changed

+37
-29
lines changed
  • content/shared/v3-enterprise-get-started

1 file changed

+37
-29
lines changed

content/shared/v3-enterprise-get-started/_index.md

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,19 @@ _During the beta period, licenses are valid until May 7, 2025._
234234

235235
### Authentication and authorization
236236

237-
{{% product-name %}} uses token-based authentication and authorization which is enabled by default when you start the server.
238-
With authentication enabled, you must provide an _admin token_ or _database token_ to access the server.
239-
240-
- **admin token**: Grants access to all CLI actions and API endpoints.
241-
_ **database token**: Scoped to a specific database and grant access to write and query data in that database.
242-
Creating a database token requires an admin token.
243-
244237
After you have [started the server](#start-influxdb), you can create and manage tokens using the `influxdb3` CLI or the HTTP API.
238+
{{% product-name %}} uses token-based authentication and authorization which is enabled by default when you start the server.
239+
With authentication enabled, you must provide a token to access server actions.
240+
{{% product-name %}} supports the following types of tokens:
245241

246-
When you create a token InfluxDB 3 returns a token string in clear text
247-
that you can use to authenticate CLI commands (using ) and API requests.
242+
- **admin token**: Grants access to all CLI actions and API endpoints. A server can have one admin token.
243+
- **resource tokens**: Fine-grained permissions tokens that grant read and write access to specific resources (databases and system information endpoints) on the server.
248244

245+
- Database tokens are scoped to a specific database and grant access to write and query data in that database. You can create multiple resource tokens for different databases
246+
- System tokens grant read access to system information and metrics for the server
249247

248+
When you create a token, InfluxDB 3 returns a token string in clear text
249+
that you use to authenticate CLI commands and API requests.
250250
Securely store your token, as you won't be able to retrieve it later.
251251

252252
To have the `influxdb3` CLI use your admin token automatically, assign it to the
@@ -264,24 +264,16 @@ To have the `influxdb3` CLI use your admin token automatically, assign it to the
264264
To create an admin token, use the `influxdb3 create token` subcommand and pass the `--admin` flag--for example:
265265

266266
```bash
267-
influxdb3 create token --admin \
267+
influxdb3 create token --admin \
268268
--host http://{{< influxdb/host >}}
269269
```
270270

271271
The command returns a token string that you can use to authenticate CLI commands and API requests.
272272
Securely store your token, as you won't be able to retrieve it later.
273273

274-
To have the `influxdb3` CLI use your admin token automatically, assign it to the
275-
`INFLUXDB3_AUTH_TOKEN` environment variable.
276-
277274
After you have created an admin token, you can use it to create database tokens and system tokens.
278275

279-
> [!Important]
280-
>
281-
> #### Securely store your tokens
282-
>
283-
> For security, InfluxDB only lets you view tokens when you create them.
284-
> InfluxDB 3 stores a hash of the token in the catalog, so you can't retrieve the token after it is created.
276+
For more information, see how to [Manage admin tokens](/influxdb3/version/admin/tokens/admin/).
285277

286278
#### Create a database token
287279

@@ -293,8 +285,8 @@ To create a database token, use the `influxdb3 create token` subcommand and pass
293285
- `--expiry` option with the token expiration time as a [duration](/influxdb3/enterprise/reference/glossary/#duration).
294286
If an expiration isn't set, the token does not expire until revoked.
295287
- `--token` option with the admin token to use for authentication
296-
- Token permissions (read and write) in the `RESOURCE_TYPE:RESOURCE_NAMES:ACTIONS` format--for example:
297-
- db:mydb:read,write
288+
- Token permissions as a string literal in the `RESOURCE_TYPE:RESOURCE_NAMES:ACTIONS` format--for example:
289+
- `"db:mydb:read,write"`
298290
- `db:`: The `db` resource type, which specifies the token is for a database.
299291
- `mydb`: The name of the database to grant permissions to. This part supports the `*` wildcard, which grants permissions to all databases.
300292
- `read,write`: The permissions to grant to the token.
@@ -332,23 +324,39 @@ To create a system token, use the `influxdb3 create token` subcommand and pass t
332324
If an expiration isn't set, the token does not expire until revoked.
333325
- `--token` option with the admin token to use for authentication
334326
- `--host` option with the server host
335-
- Token permissions (read) in the `RESOURCE_TYPE:RESOURCE_NAMES:ACTIONS` format--for example:
336-
- system:*:read
337-
- `db:`: The `db` resource type, which specifies the token is for a database.
338-
- `mydb`: The name of the database to grant permissions to. This part supports the `*` wildcard, which grants permissions to all databases.
339-
- `read,write`: The permissions to grant to the token.
327+
- Token permissions as a string literal in the `RESOURCE_TYPE:RESOURCE_NAMES:ACTIONS` format--for example:
328+
- `"system:health:read"` or `"system:*:read"`
329+
- `system:`: The `system` resource type, which specifies the token is for a database.
330+
- `health`: The system resource (endpoint) to grant permissions to. This part supports the `*` wildcard, which grants permissions to all databases.
331+
- `read`: Grant read permission to system information resources.
332+
333+
The following example shows how to create a system token that expires in 1 year and has read permissions for all system endpoints on the server:
340334

335+
```bash
336+
influxdb3 create token \
337+
--permission \
338+
--expiry 1y \
339+
--token ADMIN_TOKEN \
340+
--host http://{{< influxdb/host >}} \
341+
--name "rw all system endpoints" \
342+
"system:*:read"
343+
```
341344

345+
For more information, see how to [Manage resource tokens](/influxdb3/version/admin/tokens/resource/).
342346

343347
#### Use tokens to authorize CLI commands and API requests
344348

345349
- To authenticate `influxdb3` CLI commands, use the `--token` option or assign your
346350
token to the `INFLUXDB3_AUTH_TOKEN` environment variable for `influxdb3` to use it automatically.
347-
- To authenticate HTTP API requests, include `Bearer <TOKEN>` in the `Authorization` header--for example:
351+
- To authenticate HTTP API requests, include `Bearer <TOKEN>` in the `Authorization` header value--for example:
348352

349353
```bash
350-
curl \
351-
"http://{{< influxdb/host >}}/api/v3/query_sql?db=mydb" \
354+
curl "http://{{< influxdb/host >}}/health" \
355+
--header "Authorization: Bearer SYSTEM_TOKEN"
356+
```
357+
358+
In your request, replace
359+
{{% code-placeholder-key %}}`SYSTEM_TOKEN`{{% /code-placeholder-key %}} with the system token you created earlier.
352360

353361
### Data model
354362

0 commit comments

Comments
 (0)