Skip to content

Commit f2d8820

Browse files
authored
fix:alg is now required in jwt middleware (#804)
1 parent 7bd0c1f commit f2d8820

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/middleware/builtin/jwt.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ app.use(
2929
'/auth/*',
3030
jwt({
3131
secret: 'it-is-very-secret',
32+
alg: 'HS256',
3233
})
3334
)
3435

@@ -46,6 +47,7 @@ app.use(
4647
'/auth/*',
4748
jwt({
4849
secret: 'it-is-very-secret',
50+
alg: 'HS256',
4951
issuer: 'my-trusted-issuer',
5052
})
5153
)
@@ -64,6 +66,7 @@ app.get('/auth/page', (c) => {
6466
app.use('/auth/*', (c, next) => {
6567
const jwtMiddleware = jwt({
6668
secret: c.env.JWT_SECRET,
69+
alg: 'HS256',
6770
})
6871
return jwtMiddleware(c, next)
6972
})
@@ -77,15 +80,15 @@ app.use('/auth/*', (c, next) => {
7780

7881
A value of your secret key.
7982

80-
### <Badge type="info" text="optional" /> cookie: `string`
83+
### <Badge type="danger" text="required" /> alg: `string`
8184

82-
If this value is set, then the value is retrieved from the cookie header using that value as a key, which is then validated as a token.
85+
An algorithm type that is used for verifying.
8386

84-
### <Badge type="info" text="optional" /> alg: `string`
87+
Available types are `HS256` | `HS384` | `HS512` | `RS256` | `RS384` | `RS512` | `PS256` | `PS384` | `PS512` | `ES256` | `ES384` | `ES512` | `EdDSA`.
8588

86-
An algorithm type that is used for verifying. The default is `HS256`.
89+
### <Badge type="info" text="optional" /> cookie: `string`
8790

88-
Available types are `HS256` | `HS384` | `HS512` | `RS256` | `RS384` | `RS512` | `PS256` | `PS384` | `PS512` | `ES256` | `ES384` | `ES512` | `EdDSA`.
91+
If this value is set, then the value is retrieved from the cookie header using that value as a key, which is then validated as a token.
8992

9093
### <Badge type="info" text="optional" /> headerName: `string`
9194

@@ -96,6 +99,7 @@ app.use(
9699
'/auth/*',
97100
jwt({
98101
secret: 'it-is-very-secret',
102+
alg: 'HS256',
99103
headerName: 'x-custom-auth-header',
100104
})
101105
)

0 commit comments

Comments
 (0)