Skip to content

Commit 9a2db4a

Browse files
Merge pull request #378 from Tharsanan1/jwt-auth
Add jwt authentication policy
2 parents 3052330 + cc7ad61 commit 9a2db4a

File tree

10 files changed

+2572
-161
lines changed

10 files changed

+2572
-161
lines changed

gateway/policies/basic-auth/v1.0.0/policy-definition.yaml

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,37 @@ description: |
66
metadata in the request context for downstream policies to use.
77
88
parameters:
9-
- name: username
10-
type: string
11-
required: true
12-
description: |
13-
Expected username for authentication.
14-
Compared against the username in the Basic auth header.
15-
validation:
9+
type: object
10+
properties:
11+
username:
12+
type: string
13+
description: Expected username for authentication. Compared against the username
14+
in the Basic auth header.
1615
minLength: 1
1716
maxLength: 256
18-
19-
- name: password
20-
type: string
21-
required: true
22-
description: |
23-
Expected password for authentication.
24-
Compared against the password in the Basic auth header.
25-
validation:
17+
password:
18+
type: string
19+
description: Expected password for authentication. Compared against the password
20+
in the Basic auth header.
2621
minLength: 1
2722
maxLength: 256
28-
29-
- name: allowUnauthenticated
30-
type: boolean
31-
required: false
32-
default: false
33-
description: |
34-
If true, allows unauthenticated requests to proceed to upstream.
35-
Authentication status is still recorded in metadata (auth.success = false).
36-
If false (default), returns 401 Unauthorized for failed authentication.
37-
38-
- name: realm
39-
type: string
40-
required: false
41-
default: "Restricted"
42-
description: |
43-
Authentication realm shown in the WWW-Authenticate header.
44-
Displayed to users in browser authentication prompts.
45-
validation:
23+
allowUnauthenticated:
24+
type: boolean
25+
description: If true, allows unauthenticated requests to proceed to upstream.
26+
Authentication status is still recorded in metadata (auth.success = false).
27+
If false (default), returns 401 Unauthorized for failed authentication.
28+
default: false
29+
realm:
30+
type: string
31+
description: Authentication realm shown in the WWW-Authenticate header. Displayed
32+
to users in browser authentication prompts.
4633
minLength: 1
4734
maxLength: 256
35+
default: Restricted
36+
required:
37+
- username
38+
- password
4839

49-
initParameters: []
40+
initParameters:
41+
type: object
42+
properties: {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/policy-engine/policies/jwt-auth
2+
3+
go 1.23.0
4+
5+
require (
6+
github.com/golang-jwt/jwt/v5 v5.2.2
7+
github.com/wso2/api-platform/sdk v1.0.0
8+
)
9+
10+
replace github.com/wso2/api-platform/sdk => ../../../../sdk
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
2+
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=

0 commit comments

Comments
 (0)