Mercurial > hg > nginx-site
diff xml/en/docs/njs/examples.xml @ 2780:bf641527bd3d
Updated jwt_field example in njs Examples.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Fri, 15 Oct 2021 20:14:49 +0100 |
parents | 9cafae0b7ef3 |
children | 24b379907b0f |
line wrap: on
line diff
--- a/xml/en/docs/njs/examples.xml Fri Oct 15 20:13:02 2021 +0100 +++ b/xml/en/docs/njs/examples.xml Fri Oct 15 20:14:49 2021 +0100 @@ -9,7 +9,7 @@ <article name="Examples" link="/en/docs/njs/examples.html" lang="en" - rev="19"> + rev="20"> <section id="summary"> @@ -148,6 +148,12 @@ as nginx Variable"> <para> +In the following example, the <literal>sub</literal> field +is extracted from JWT payload. +The JWT token is taken from the <header>Authorization</header> header. +</para> + +<para> <path>nginx.conf</path>: <example> js_import http.js; @@ -176,6 +182,8 @@ function jwt_payload_sub(r) { return jwt(r.headersIn.Authorization.slice(7)).payload.sub; + // when the token is provided as the "myjwt" argument + // return jwt(r.args.myjwt).payload.sub; } export default {jwt_payload_sub};