You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/latest/plugin-develop.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -439,19 +439,20 @@ end
439
439
440
440
## register public API
441
441
442
-
A plugin can register API which exposes to the public. Take jwt-auth plugin as an example, this plugin registers `GET /apisix/plugin/jwt/sign` to allow client to sign its key:
442
+
A plugin can register API which exposes to the public. Take batch-requests plugin as an example, this plugin registers `POST /apisix/batch-requests` to allow developers to group multiple API requests into a single HTTP request/response cycle:
Copy file name to clipboardExpand all lines: docs/en/latest/plugins/jwt-auth.md
+7-57Lines changed: 7 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,13 +43,12 @@ For Consumer:
43
43
| key | string | True ||| Unique key for a Consumer. |
44
44
| secret | string | False ||| The encryption key. If unspecified, auto generated in the background. This field supports saving the value in Secret Manager using the [APISIX Secret](../terminology/secret.md) resource. |
45
45
| public_key | string | True if `RS256` or `ES256` is set for the `algorithm` attribute. ||| RSA or ECDSA public key. This field supports saving the value in Secret Manager using the [APISIX Secret](../terminology/secret.md) resource. |
46
-
| private_key | string | True if `RS256` or `ES256` is set for the `algorithm` attribute. ||| RSA or ECDSA private key. This field supports saving the value in Secret Manager using the [APISIX Secret](../terminology/secret.md) resource. |
| exp | integer | False | 86400 |[1,...]| Expiry time of the token in seconds. |
49
48
| base64_secret | boolean | False | false || Set to true if the secret is base64 encoded. |
50
49
| lifetime_grace_period | integer | False | 0 |[0,...]| Define the leeway in seconds to account for clock skew between the server that generated the jwt and the server validating it. Value should be zero (0) or a positive integer. |
51
50
52
-
NOTE: `encrypt_fields = {"secret", "private_key"}` is also defined in the schema, which means that the field will be stored encrypted in etcd. See [encrypted storage fields](../plugin-develop.md#encrypted-storage-fields).
51
+
NOTE: `encrypt_fields = {"secret"}` is also defined in the schema, which means that the field will be stored encrypted in etcd. See [encrypted storage fields](../plugin-develop.md#encrypted-storage-fields).
53
52
54
53
For Route:
55
54
@@ -62,16 +61,6 @@ For Route:
62
61
63
62
You can implement `jwt-auth` with [HashiCorp Vault](https://www.vaultproject.io/) to store and fetch secrets and RSA keys pairs from its [encrypted KV engine](https://developer.hashicorp.com/vault/docs/secrets/kv) using the [APISIX Secret](../terminology/secret.md) resource.
64
63
65
-
## API
66
-
67
-
This Plugin adds `/apisix/plugin/jwt/sign` as an endpoint.
68
-
69
-
:::note
70
-
71
-
You may need to use the [public-api](public-api.md) plugin to expose this endpoint.
72
-
73
-
:::
74
-
75
64
## Enable Plugin
76
65
77
66
To enable the Plugin, you have to create a Consumer object with the JWT token and configure your Route to use JWT authentication.
The `jwt-auth` Plugin uses the HS256 algorithm by default. To use the RS256 algorithm, you can configure the public key and private key and specify the algorithm:
94
+
The `jwt-auth` Plugin uses the HS256 algorithm by default. To use the RS256 algorithm, you can configure the public key and specify the algorithm:
106
95
107
96
```shell
108
97
curl http://127.0.0.1:9180/apisix/admin/consumers -H "X-API-KEY: $admin_key" -X PUT -d '
When you are issuing a JWT token, you have to update the payload with `key` matching the credential key you would like to use; and `exp` or `nbf` in UNIX timestamp.
187
144
188
-
```
189
-
HTTP/1.1 200 OK
190
-
Date: Wed, 21 Apr 2021 06:43:59 GMT
191
-
Content-Type: text/plain; charset=utf-8
192
-
Transfer-Encoding: chunked
193
-
Connection: keep-alive
194
-
Server: APISIX/2.4
145
+
e.g. payload=`{"key": "user-key", "exp": 1727274983}`
0 commit comments