Skip to content

Commit

Permalink
feat: fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
fishioon committed Oct 12, 2023
1 parent 26cee67 commit b51f672
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apisix/plugins/jwe-decrypt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local base64 = require("ngx.base64")
local ngx = ngx
local sub_str = string.sub
local plugin_name = "jwe-decrypt"
local cipher = assert(require("resty.openssl.cipher").new("aes-256-gcm"))
local cipher = require("resty.openssl.cipher").new("aes-256-gcm")

local schema = {
type = "object",
Expand Down Expand Up @@ -54,7 +54,7 @@ local consumer_schema = {

local _M = {
version = 0.1,
priority = 2510,
priority = 2509,
type = 'auth',
name = plugin_name,
schema = schema,
Expand Down
2 changes: 1 addition & 1 deletion conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ plugins: # plugin list (sorted by priority)
- uri-blocker # priority: 2900
- request-validation # priority: 2800
- chaitin-waf # priority: 2700
- jwe-decrypt # priority: 2600
- openid-connect # priority: 2599
- cas-auth # priority: 2597
- authz-casbin # priority: 2560
Expand All @@ -466,6 +465,7 @@ plugins: # plugin list (sorted by priority)
- hmac-auth # priority: 2530
- basic-auth # priority: 2520
- jwt-auth # priority: 2510
- jwe-decrypt # priority: 2509
- key-auth # priority: 2500
- consumer-restriction # priority: 2400
- forward-auth # priority: 2002
Expand Down
1 change: 1 addition & 0 deletions docs/en/latest/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"items": [
"plugins/key-auth",
"plugins/jwt-auth",
"plugins/jwe-decrypt",
"plugins/basic-auth",
"plugins/authz-keycloak",
"plugins/authz-casdoor",
Expand Down
5 changes: 4 additions & 1 deletion docs/en/latest/plugins/jwe-decrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ curl http://127.0.0.1:9180/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f1
}'
```

:::
:::note

Once you have created a Consumer object, you can configure a Route to decrypt the header:

Expand All @@ -101,6 +101,8 @@ curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```

:::

## Example usage

You need to first setup a Route for an API that signs the token using the [public-api](public-api.md) Plugin:
Expand Down Expand Up @@ -140,6 +142,7 @@ curl http://127.0.0.1:9080/anything/hello -H 'Authorization: eyJhbGciOiJkaXIiLCJ
```

You can see header "Authorization" change to plaintext.

```
HTTP/1.1 200 OK
Content-Type: application/json
Expand Down
3 changes: 2 additions & 1 deletion rockspec/apisix-master-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ dependencies = {
"nanoid = 0.1-1",
"lua-resty-mediador = 0.1.2-1",
"lua-resty-ldap = 0.1.0-0",
"lua-resty-t1k = 1.1.0"
"lua-resty-t1k = 1.1.0",
"lua-resty-openssl = 0.8.25-1"
}

build = {
Expand Down
3 changes: 2 additions & 1 deletion t/admin/plugins.t
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ ldap-auth
hmac-auth
basic-auth
jwt-auth
jwe-decrypt
key-auth
consumer-restriction
forward-auth
Expand Down Expand Up @@ -311,7 +312,7 @@ qr/\{"metadata_schema":\{"properties":\{"ikey":\{"minimum":0,"type":"number"\},"
}
}
--- response_body eval
qr/\[\{"name":"wolf-rbac","priority":2555\},\{"name":"ldap-auth","priority":2540\},\{"name":"hmac-auth","priority":2530\},\{"name":"basic-auth","priority":2520\},\{"name":"jwt-auth","priority":2510\},\{"name":"key-auth","priority":2500\}\]/
qr/\[\{"name":"wolf-rbac","priority":2555\},\{"name":"ldap-auth","priority":2540\},\{"name":"hmac-auth","priority":2530\},\{"name":"basic-auth","priority":2520\},\{"name":"jwt-auth","priority":2510\},\{"name":"jwe-decrypt","priority":2509\},\{"name":"key-auth","priority":2500\}\]/
Expand Down
4 changes: 4 additions & 0 deletions t/plugin/jwe-decrypt.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ qr/{"key":"123","secret":"[a-zA-Z0-9+\\\/]+={0,2}"}/
property "key" validation failed: wrong type: expected string, got number
done
=== TEST 3: wrong type of string
--- config
location /t {
Expand All @@ -90,6 +92,8 @@ done
property "secret" validation failed: string too short, expected at least 32, got 6
done
=== TEST 4: add consumer with username and plugins
--- config
location /t {
Expand Down

0 comments on commit b51f672

Please sign in to comment.