Skip to content

Commit 0d13e2c

Browse files
defguard-communitygitbook-bot
authored andcommitted
GITBOOK-340: API tokens
1 parent f4afc49 commit 0d13e2c

File tree

8 files changed

+62
-0
lines changed

8 files changed

+62
-0
lines changed

.gitbook/assets/image (62).png

93.8 KB
Loading

.gitbook/assets/image (63).png

12 KB
Loading

.gitbook/assets/image (64).png

12.4 KB
Loading

.gitbook/assets/image (65).png

20.4 KB
Loading

.gitbook/assets/image (66).png

36.8 KB
Loading

SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
* [Custom](enterprise/all-enteprise-features/external-openid-providers/custom.md)
8484
* [External OIDC secure enrollment](enterprise/all-enteprise-features/external-oidc-secure-enrollment.md)
8585
* [VPN & Client behavior customization](enterprise/all-enteprise-features/behavior-customization.md)
86+
* [API tokens](enterprise/all-enteprise-features/api-tokens.md)
8687

8788
## Tutorials
8889

enterprise/all-enteprise-features/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Here is a list of all Enterprise features:
1212
* Ability to [disable for users to manage their devices](behavior-customization.md#disable-for-users-to-manage-their-devices) (just admin will have this possibility).
1313
* Ability to [disable for users to configure WireGuard clients other then defguard desktop client](behavior-customization.md#disable-ability-to-configure-other-vpn-clients-then-defguard-desktop-client).
1414
* Ability to [disable "All traffic" in the desktop client ](behavior-customization.md#disable-all-traffic-option-in-the-desktop-client)- just "predefined" traffic by admins.
15+
* Ability to integrate with external tooling using [API tokens](api-tokens.md).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
icon: key-skeleton
3+
---
4+
5+
# API tokens
6+
7+
{% hint style="warning" %}
8+
API token functionality requires defguard version 1.2.4+.
9+
{% endhint %}
10+
11+
12+
13+
Admin users can generate API tokens to enable request authentication for custom external tools which use defguard REST API.
14+
15+
Tokens retain the same access permissions as their owner, so be careful when sharing them with others.
16+
17+
## Setup
18+
19+
To generate a new API token go to your profile page and click the `Add new API Token`button:
20+
21+
<figure><img src="../../.gitbook/assets/image (62).png" alt=""><figcaption></figcaption></figure>
22+
23+
Fill in your chosen token name and submit form:
24+
25+
<figure><img src="../../.gitbook/assets/image (64).png" alt=""><figcaption></figcaption></figure>
26+
27+
Copy generated token. This is the only time the token will be available in plain text form. If you lose it you will have to generate a new one.
28+
29+
<figure><img src="../../.gitbook/assets/image (65).png" alt=""><figcaption></figcaption></figure>
30+
31+
In the API token list you can later rename or delete a token:
32+
33+
<figure><img src="../../.gitbook/assets/image (66).png" alt=""><figcaption></figcaption></figure>
34+
35+
## Usage
36+
37+
defguard API uses a standard **Bearer token authentication** scheme.
38+
39+
This means that an API token can be passed in the `Authorization`header to authenticate a given request instead of a session cookie used by the web UI:
40+
41+
```bash
42+
Authorization: Bearer <token>
43+
```
44+
45+
Example GET request:
46+
47+
```bash
48+
curl -H "Authorization: Bearer <token>" <YOUR_DEFGUARD_URL>/api/v1/me
49+
```
50+
51+
## REST API documentation
52+
53+
You can explore the defguard REST API using [Swagger UI](https://swagger.io/tools/swagger-ui/) by going to `<YOUR_DEFGUARD_URL>/api-docs`.
54+
55+
API specification JSON in OpenAPI format can also be fetched from `<YOUR_DEFGUARD_URL>/api/v1/api-docs`.
56+
57+
58+
59+
60+

0 commit comments

Comments
 (0)