Skip to content

Commit 21ad484

Browse files
committed
feat(enterprise): Get-started using admin, database, and system tokens
1 parent f100650 commit 21ad484

File tree

1 file changed

+118
-0
lines changed
  • content/shared/v3-enterprise-get-started

1 file changed

+118
-0
lines changed

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

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,124 @@ Upon verification, the license creation, retrieval, and application are automate
232232

233233
_During the beta period, licenses are valid until May 7, 2025._
234234

235+
### Authentication and authorization
236+
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+
244+
After you have [started the server](#start-influxdb), you can create and manage tokens using the `influxdb3` CLI or the HTTP API.
245+
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.
248+
249+
250+
Securely store your token, as you won't be able to retrieve it later.
251+
252+
To have the `influxdb3` CLI use your admin token automatically, assign it to the
253+
`INFLUXDB3_AUTH_TOKEN` environment variable.
254+
255+
> [!Important]
256+
>
257+
> #### Securely store your tokens
258+
>
259+
> For security, InfluxDB only lets you view tokens when you create them.
260+
> InfluxDB 3 stores a hash of the token in the catalog, so you can't retrieve the token after it is created.
261+
262+
#### Create an admin token
263+
264+
To create an admin token, use the `influxdb3 create token` subcommand and pass the `--admin` flag--for example:
265+
266+
```bash
267+
influxdb3 create token --admin \
268+
--host http://{{< influxdb/host >}}
269+
```
270+
271+
The command returns a token string that you can use to authenticate CLI commands and API requests.
272+
Securely store your token, as you won't be able to retrieve it later.
273+
274+
To have the `influxdb3` CLI use your admin token automatically, assign it to the
275+
`INFLUXDB3_AUTH_TOKEN` environment variable.
276+
277+
After you have created an admin token, you can use it to create database tokens and system tokens.
278+
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.
285+
286+
#### Create a database token
287+
288+
To create a database token, use the `influxdb3 create token` subcommand and pass the following:
289+
290+
- `--permission`: Create a token with permissions
291+
- `--name`: A unique description of the token
292+
- _Options_, for example:
293+
- `--expiry` option with the token expiration time as a [duration](/influxdb3/enterprise/reference/glossary/#duration).
294+
If an expiration isn't set, the token does not expire until revoked.
295+
- `--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
298+
- `db:`: The `db` resource type, which specifies the token is for a database.
299+
- `mydb`: The name of the database to grant permissions to. This part supports the `*` wildcard, which grants permissions to all databases.
300+
- `read,write`: The permissions to grant to the token.
301+
302+
The following example shows how to create a database token that expires in 90 days and has read and write permissions for all databases on the server:
303+
304+
{{% code-placeholders "ADMIN_TOKEN" %}}
305+
```bash
306+
influxdb3 create token \
307+
--permission \
308+
--expiry 90d \
309+
--token ADMIN_TOKEN \
310+
--host http://{{< influxdb/host >}} \
311+
--name "rw all databases" \
312+
"db:*:read,write"
313+
```
314+
{{% /code-placeholders %}}
315+
316+
In your command, replace {{% code-placeholder-key %}} `ADMIN_TOKEN`{{% /code-placeholder-key %}}
317+
with the admin token you created earlier.
318+
319+
#### Create a system token
320+
321+
A _system token_ grants read access to system information and metrics for the server, including the following HTTP API endpoints:
322+
323+
- `/health`
324+
- `/metrics`
325+
- `/ping`
326+
327+
To create a system token, use the `influxdb3 create token` subcommand and pass the following:
328+
- `--permission`: Create a token with permissions
329+
- `--name`: A unique description of the token
330+
- _Options_, for example:
331+
- `--expiry` option with the token expiration time as a [duration](/influxdb3/enterprise/reference/glossary/#duration).
332+
If an expiration isn't set, the token does not expire until revoked.
333+
- `--token` option with the admin token to use for authentication
334+
- `--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.
340+
341+
342+
343+
#### Use tokens to authorize CLI commands and API requests
344+
345+
- To authenticate `influxdb3` CLI commands, use the `--token` option or assign your
346+
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:
348+
349+
```bash
350+
curl \
351+
"http://{{< influxdb/host >}}/api/v3/query_sql?db=mydb" \
352+
235353
### Data model
236354

237355
The database server contains logical databases, which have tables, which have columns. Compared to previous versions of InfluxDB you can think of a database as a `bucket` in v2 or as a `db/retention_policy` in v1. A `table` is equivalent to a `measurement`, which has columns that can be of type `tag` (a string dictionary), `int64`, `float64`, `uint64`, `bool`, or `string` and finally every table has a `time` column that is a nanosecond precision timestamp.

0 commit comments

Comments
 (0)