@@ -25,6 +25,7 @@ app.use(
2525 ' /auth/*' ,
2626 jwk ({
2727 jwks_uri: ` https://${backendServer }/.well-known/jwks.json ` ,
28+ alg: [' RS256' ],
2829 })
2930)
3031
@@ -42,6 +43,7 @@ app.use(
4243 ' /auth/*' ,
4344 jwk ({
4445 jwks_uri: ` https://${backendServer }/.well-known/jwks.json ` ,
46+ alg: [' RS256' ],
4547 })
4648)
4749
@@ -61,6 +63,7 @@ app.use(
6163 jwk ({
6264 jwks_uri : (c ) =>
6365 ` https://${c .env .authServer }/.well-known/jwks.json ` ,
66+ alg: [' RS256' ],
6467 allow_anon: true ,
6568 })
6669)
@@ -88,8 +91,39 @@ const id_payload = await verifyWithJwks(
8891)
8992```
9093
94+ ## Configuring JWKS fetch request options
95+
96+ To configure how JWKS is retrieved from ` jwks_uri ` , pass fetch request options as the second argument of ` jwk() ` .
97+
98+ This argument is ` RequestInit ` and is used only for the JWKS fetch request.
99+
100+ ``` ts
101+ const app = new Hono ()
102+
103+ app .use (
104+ ' /auth/*' ,
105+ jwk (
106+ {
107+ jwks_uri: ` https://${backendServer }/.well-known/jwks.json ` ,
108+ alg: [' RS256' ],
109+ },
110+ {
111+ headers: {
112+ Authorization: ' Bearer TOKEN' ,
113+ },
114+ }
115+ )
116+ )
117+ ```
118+
91119## Options
92120
121+ ### <Badge type =" danger " text =" required " /> alg: ` AsymmetricAlgorithm[] `
122+
123+ An array of allowed asymmetric algorithms used for token verification.
124+
125+ Available types are ` RS256 ` | ` RS384 ` | ` RS512 ` | ` PS256 ` | ` PS384 ` | ` PS512 ` | ` ES256 ` | ` ES384 ` | ` ES512 ` | ` EdDSA ` .
126+
93127### <Badge type =" info " text =" optional " /> keys: ` HonoJsonWebKey[] | (c: Context) => Promise<HonoJsonWebKey[]> `
94128
95129The values of your public keys, or a function that returns them. The function receives the Context object.
@@ -109,3 +143,7 @@ If this value is set, then the value is retrieved from the cookie header using t
109143### <Badge type =" info " text =" optional " /> headerName: ` string `
110144
111145The name of the header to look for the JWT token. The default is ` Authorization ` .
146+
147+ ### <Badge type =" info " text =" optional " /> verification: ` VerifyOptions `
148+
149+ If this option is set, you can specify validation rules for claims in the JWT payload (` iss ` / ` aud ` / ` exp ` / ` nbf ` / ` iat ` ), in addition to signature verification.
0 commit comments