jwt-realm.asciidoc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. [role="xpack"]
  2. [[jwt-auth-realm]]
  3. === JWT authentication
  4. beta::[]
  5. {es} can be configured to trust JSON Web Tokens (JWTs) that are issued as an
  6. authentication credential from an external service.
  7. When a JWT realm is used to authenticate with {es}, a distinction is made
  8. between the _client_ that is connecting to {es}, and the _user_ on whose behalf
  9. the request should run. The JWT identifies the user, and a separate credential
  10. is used to authenticate the client.
  11. A common scenario that uses JWTs is when an existing front-end application uses
  12. OpenID Connect (OIDC) as an authentication method, and then accesses {es}
  13. on behalf of the authenticated user.
  14. TIP: If the front-end application does not exist, you can use the
  15. <<token-authentication-services>> instead.
  16. [[jwt-realm-oidc]]
  17. ==== JWT uses OIDC workflows
  18. JWT authentication in {es} is derived from OIDC workflows, where different
  19. tokens can be issued by an OIDC Provider (OP). One possible token is an
  20. _ID token_, which uses the JWT format. If the ID token is presented to a JWT
  21. realm, {es} can use it to authenticate, identify, and authorize an individual
  22. user.
  23. NOTE: Because JWTs are external to {es}, you can define a custom workflow
  24. instead of using the OIDC workflow. However, the JWT format must still be JSON
  25. Web Signature (JWS). The JWS header and JWS signature are validated using OIDC
  26. ID token validation rules.
  27. {es} supports a separate <<oidc-realm,OpenID Connect realm>>, which provides
  28. stronger security guarantees than the JWT realm and is preferred for any
  29. use case where {es} can act as an OIDC RP. The OIDC realm is the only supported
  30. way to enable OIDC authentication in {kib}.
  31. [[jwt-realm-configuration]]
  32. ==== Configure {es} to use a JWT realm
  33. To use JWT authentication, create the realm in the `elasticsearch.yml` file
  34. to configure it within the {es} authentication chain.
  35. The JWT realm has a few mandatory settings, plus optional settings that are
  36. described in <<ref-jwt-settings,JWT realm settings>>.
  37. NOTE: Client authentication is enabled by default for the JWT realms. Disabling
  38. client authentication is possible, but strongly discouraged.
  39. . Add your JWT realm to the `elasticsearch.yml` file. The following example
  40. includes the most common settings, which are not intended for every use case:
  41. +
  42. --
  43. [source,yaml]
  44. ----
  45. xpack.security.authc.realms.jwt.jwt1:
  46. order: 3
  47. client_authentication.type: shared_secret
  48. allowed_issuer: "https://issuer.example.com/jwt/"
  49. allowed_audiences: [ "8fb85eba-979c-496c-8ae2-a57fde3f12d0" ]
  50. allowed_signature_algorithms: [RS256,HS256]
  51. pkc_jwkset_path: jwt/jwkset.json
  52. claims.principal: sub
  53. ----
  54. `order`::
  55. Specifies a realm `order` of `3`, which indicates the order in which the
  56. configured realm is checked when authenticating a user. Realms are consulted in
  57. ascending order, where the realm with the lowest order value is consulted first.
  58. `client_authentication.type`::
  59. Specifies the client authentication type as `shared_secret`, which means that
  60. the client is authenticated using an HTTP request header that must match a
  61. pre-configured secret value. The client must provide this shared secret with
  62. every request in the `ES-Client-Authentication` header. The value must be a
  63. case-insensitive match to the realm's `client_authentication.shared_secret`.
  64. `allowed_issuer`::
  65. Sets a verifiable identifier for your JWT issuer. This value is typically a
  66. URL, UUID, or some other case-sensitive string value.
  67. `allowed_audiences`::
  68. Specifies a list of JWT audiences that the realm will allow.
  69. These values are typically URLs, UUIDs, or other case-sensitive string values.
  70. `allowed_signature_algorithms`::
  71. Indicates that {es} should use the `RS256` or `HS256` signature algorithms to
  72. verify the signature of the JWT from the JWT issuer.
  73. `pkc_jwkset_path`::
  74. The file path to a JSON Web Key Set (JWKS) containing the public key material
  75. that the JWT realm uses to verify JWT signatures. If a path is provided,
  76. then it is resolved relative to the {es} configuration directory. In {ecloud},
  77. use an absolute path starting with `/app/config/`.
  78. `claims.principal`::
  79. The name of the JWT claim that contains the user's principal (username).
  80. --
  81. . After defining settings, use the
  82. {ref}/elasticsearch-keystore.html[`elasticsearch-keystore`] tool to store
  83. values for secure settings in the {es} keystore.
  84. .. Store the `shared_secret` value for `client_authentication.type`:
  85. +
  86. [source,shell]
  87. ----
  88. bin/elasticsearch-keystore add xpack.security.authc.realms.jwt.jwt1.client_authentication.shared_secret
  89. ----
  90. .. Store the HMAC keys for `allowed_signature_algorithms`, which use the HMAC
  91. SHA-256 algorithm `HS256` in the example:
  92. +
  93. [source,shell]
  94. ----
  95. bin/elasticsearch-keystore add-file xpack.security.authc.realms.jwt.jwt1.hmac_jwkset <path> <1>
  96. ----
  97. <1> Path to a JWKS, which is a resource for a set of JSON-encoded secret keys.
  98. The file can be removed after you load the contents into the {es} keystore.
  99. +
  100. [NOTE]
  101. ====
  102. Using the JWKS is preferred. However, you can add an HMAC key in string format
  103. using the following command. This format is compatible with OIDC HMAC keys, but
  104. only supports a single key with no attributes. You can only use one HMAC format
  105. (either `hmac_jwkset` or `hmac_key`) simultaneously.
  106. [source,shell]
  107. ----
  108. bin/elasticsearch-keystore add xpack.security.authc.realms.jwt.jwt1.hmac_key
  109. ----
  110. ====
  111. [[jwt-validation]]
  112. ==== JWT encoding and validation
  113. JWTs can be parsed into three pieces:
  114. Header::
  115. Provides information about how to validate the token.
  116. Claims::
  117. Contains data about the calling user or application.
  118. Signature::
  119. The data that's used to validate the token.
  120. [source,js]
  121. ----
  122. Header: {"typ":"JWT","alg":"HS256"}
  123. Claims: {"aud":"aud8","sub":"security_test_user","iss":"iss8","exp":4070908800,"iat":946684800}
  124. Signature: UnnFmsoFKfNmKMsVoDQmKI_3-j95PCaKdgqqau3jPMY
  125. ----
  126. // NOTCONSOLE
  127. This example illustrates a partial decoding of a JWT. The validity period is
  128. from 2000 to 2099 (inclusive), as defined by the issue time (`iat`) and
  129. expiration time (`exp`). JWTs typically have a validity period shorter than
  130. 100 years, such as 1-2 hours or 1-7 days, not an entire human life.
  131. The signature in this example is deterministic because the header, claims, and
  132. HMAC key are fixed. JWTs typically have a `nonce` claim to make the signature
  133. non-deterministic. The supported JWT encoding is JSON Web Signature (JWS), and
  134. the JWS `Header` and `Signature` are validated using OpenID Connect ID Token
  135. validation rules. Some validation is customizable through
  136. <<ref-jwt-settings,JWT realm settings>>.
  137. [[jwt-validation-header]]
  138. ===== Header claims
  139. The header claims indicate the token type and the algorithm used to sign the
  140. token.
  141. `alg`::
  142. (Required, String) Indicates the algorithm that was used to sign the token, such
  143. as `HS256`. The algorithm must be in the realm's allow list.
  144. `typ`::
  145. (Optional, String) Indicates the token type, which must be `JWT`.
  146. [[jwt-validation-payload]]
  147. ===== Payload claims
  148. OIDC ID tokens contain several claims, which provide information about the user
  149. who is issuing the token, and the token itself.
  150. [[jwt-validation-payload-oidc]]
  151. ====== OIDC payload claims
  152. The following claims are validated by a subset of OIDC ID token rules.
  153. {es} doesn't validate `nonce` claims, but a custom JWT issuer can add a
  154. random `nonce` claim to introduce entropy into the signature.
  155. NOTE: You can relax validation of any of the time-based claims by setting
  156. `allowed_clock_skew`. This value sets the maximum allowed clock skew before
  157. validating JWTs with respect to their authentication time (`auth_time`),
  158. creation (`iat`), not before (`nbf`), and expiration times (`exp`).
  159. `aud`::
  160. (Required, String) Indicates the audiences that the ID token is for, expressed as a
  161. comma-separated value (CSV). One of the values must be an exact, case-sensitive
  162. match to any of the CSV values in the `allowed_audiences` setting.
  163. `exp`::
  164. (Required, integer) Expiration time for the ID token, expressed in UTC
  165. milliseconds since epoch.
  166. `iat`::
  167. (Required, integer) Time that the ID token was issued, expressed in UTC
  168. milliseconds since epoch.
  169. `iss`::
  170. (Required, String) Denotes the issuer that created the ID token. The value must
  171. be an exact, case-sensitive match to the value in the `allowed_issuer` setting.
  172. `nbf`::
  173. (Optional, integer) Indicates the time before which the JWT must not be accepted,
  174. expressed as UTC milliseconds since epoch.
  175. `auth_time`::
  176. (Optional, integer) Time when the user authenticated to the JWT issuer,
  177. expressed as UTC milliseconds since epoch.
  178. [[jwt-validation-payload-es]]
  179. ====== {es} settings for consuming OIDC claims
  180. {es} uses OIDC ID token claims for the following settings.
  181. `principal`::
  182. (Required, String) Contains the user's principal (username). The value is
  183. configurable using the realm setting `claims.principal`. If not set, the value
  184. defaults to `sub`. You can configure an optional regular expression using the
  185. `claims.principal_pattern` to extract a substring.
  186. `groups`::
  187. (Optional, JSON array) Contains the user's group membership.
  188. The value is configurable using the realm setting `claims.groups`. You can
  189. configure an optional regular expression using the realm setting
  190. `claims.groups_pattern` to extract a substring value.
  191. `name`::
  192. (Optional, String) Contains a human-readable identifier that identifies the
  193. subject of the token. The value is configurable using the realm setting
  194. `claims.name`. You can configure an optional regular expression using the realm
  195. setting `claims.name_pattern` to extract a substring value.
  196. `mail`::
  197. (Optional, String) Contains the e-mail address to associate with the user. The
  198. value is configurable using the realm setting `claims.mail`. You can configure an
  199. optional regular expression using the realm setting `claims.mail_pattern` to
  200. extract a substring value.
  201. `dn`::
  202. (Optional, String) Contains the user's Distinguished Name (DN), which uniquely
  203. identifies a user or group. The value is configurable using the realm setting
  204. `claims.dn`. You can configure an optional regular expression using the realm
  205. setting `claims.dn_pattern` to extract a substring value.
  206. [[jwt-authorization]]
  207. ==== JWT realm authorization
  208. The JWT realm supports authorization with the create or update role mappings API,
  209. or delegating authorization to another realm. You cannot use these methods
  210. simultaneously, so choose whichever works best for your environment.
  211. IMPORTANT: You cannot map roles in the JWT realm using the `role_mapping.yml`
  212. file.
  213. [[jwt-authorization-role-mapping]]
  214. ===== Authorizing with the role mapping API
  215. You can use the
  216. <<security-api-put-role-mapping,create or update role mappings API>> to define
  217. role mappings that determine which roles should be assigned to each user based on
  218. their username, groups, or other metadata.
  219. [source,console]
  220. ----
  221. PUT /_security/role_mapping/jwt1_users?refresh=true
  222. {
  223. "roles" : [ "user" ],
  224. "rules" : { "all" : [
  225. { "field": { "realm.name": "jwt1" } },
  226. { "field": { "username": "principalname1" } },
  227. { "field": { "dn": "CN=Principal Name 1,DC=example.com" } },
  228. { "field": { "groups": "group1" } },
  229. { "field": { "metadata.jwt_claim_other": "other1" } }
  230. ] },
  231. "enabled": true
  232. }
  233. ----
  234. If you use this API in the JWT realm, the following claims are available for
  235. role mapping:
  236. `principal`::
  237. (Required, String) Principal claim that is used as the {es} user's username.
  238. `dn`::
  239. (Optional, String) Distinguished Name (DN) that is used as the {es} user's DN.
  240. `groups`::
  241. (Optional, String) Comma-separated value (CSV) list that is used as the {es}
  242. user's list of groups.
  243. `metadata`::
  244. (Optional, object) Additional metadata about the user, such as strings, integers,
  245. boolean values, and collections that are used as the {es} user's metadata.
  246. These values are key value pairs formatted as
  247. `metadata.jwt_claim_<key>` = `<value>`.
  248. [[jwt-authorization-delegation]]
  249. ===== Delegating JWT authorization to another realm
  250. If you <<authorization_realms,delegate authorization>> to other realms from the
  251. JWT realm, only the `principal` claim is available for role lookup. When
  252. delegating the assignment and lookup of roles to another realm from the JWT
  253. realm, claims for `dn`, `groups`, `mail`, `metadata`, and `name` are not used
  254. for the {es} user's values. Only the JWT `principal` claim is passed to the
  255. delegated authorization realms. The realms that are delegated for authorization
  256. - not the JWT realm - become responsible for populating all of the {es} user's
  257. values.
  258. The following example shows how you define delegation authorization in the
  259. `elasticsearch.yml` file to multiple other realms from the JWT realm. A JWT
  260. realm named `jwt2` is delegating authorization to multiple realms:
  261. [source,yaml]
  262. ----
  263. xpack.security.authc.realms.jwt.jwt2.authorization_realms: file1,native1,ldap1,ad1
  264. ----
  265. You can then use the
  266. <<security-api-put-role-mapping,create or update role mappings API>> to map
  267. roles to the authorizing realm. The following example maps roles in the `native1`
  268. realm for the `principalname1` JWT principal.
  269. [source,console]
  270. ----
  271. PUT /_security/role_mapping/native1_users?refresh=true
  272. {
  273. "roles" : [ "user" ],
  274. "rules" : { "all" : [
  275. { "field": { "realm.name": "native1" } },
  276. { "field": { "username": "principalname1" } }
  277. ] },
  278. "enabled": true
  279. }
  280. ----
  281. If realm `jwt2` successfully authenticates a client with a JWT for principal
  282. `principalname1`, and delegates authorization to one of the listed realms
  283. (such as `native1`), then that realm can look up the {es} user's values. With
  284. this defined role mapping, the realm can also look up this role mapping rule
  285. linked to realm `native1`.
  286. [[jwt-realm-runas]]
  287. ===== Applying the `run_as` privilege to JWT realm users
  288. {es} can retrieve roles for a JWT user through either role mapping or
  289. delegated authorization. Regardless of which option you choose, you can apply the
  290. <<run-as-privilege-apply,`run_as` privilege>> to a role so that a user can
  291. submit authenticated requests to "run as" a different user. To submit requests as
  292. another user, include the `es-security-runas-user` header in your requests.
  293. Requests run as if they were issued from that user and {es} uses their roles.
  294. For example, let's assume that there's a user with the username `user123_runas`.
  295. The following request creates a user role named `jwt_role1`, which specifies a
  296. `run_as` user with the `user123_runas` username. Any user with the `jwt_role1`
  297. role can issue requests as the specified `run_as` user.
  298. [source,console]
  299. ----
  300. POST /_security/role/jwt_role1?refresh=true
  301. {
  302. "cluster": ["manage"],
  303. "indices": [ { "names": [ "*" ], "privileges": ["read"] } ],
  304. "run_as": [ "user123_runas" ],
  305. "metadata" : { "version" : 1 }
  306. }
  307. ----
  308. You can then map that role to a user in a specific realm. The following request
  309. maps the `jwt_role1` role to a user with the username `user2` in the `jwt2` JWT
  310. realm. This means that {es} will use the `jwt2` realm to authenticate the user
  311. named `user2`. Because `user2` has a role (the `jwt_role1` role) that includes
  312. the `run_as` privilege, {es} retrieves the role mappings for the `user123_runas`
  313. user and uses the roles for that user to submit requests.
  314. [source,console]
  315. ----
  316. POST /_security/role_mapping/jwt_user1?refresh=true
  317. {
  318. "roles": [ "jwt_role1"],
  319. "rules" : { "all" : [
  320. { "field": { "realm.name": "jwt2" } },
  321. { "field": { "username": "user2" } }
  322. ] },
  323. "enabled": true,
  324. "metadata" : { "version" : 1 }
  325. }
  326. ----
  327. After mapping the roles, you can make an
  328. <<security-api-authenticate,authenticated call>> to {es} using a JWT and include
  329. the `ES-Client-Authentication` header:
  330. [source,sh]
  331. ----
  332. curl -s -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiZXMwMSIsImVzMDIiLCJlczAzIl0sInN1YiI6InVzZXIyIiwiaXNzIjoibXktaXNzdWVyIiwiZXhwIjo0MDcwOTA4ODAwLCJpYXQiOjk0NjY4NDgwMCwiZW1haWwiOiJ1c2VyMkBzb21ldGhpbmcuZXhhbXBsZS5jb20ifQ.UgO_9w--EoRyUKcWM5xh9SimTfMzl1aVu6ZBsRWhxQA" -H "ES-Client-Authentication: sharedsecret test-secret" https://localhost:9200/_security/_authenticate
  333. ----
  334. // NOTCONSOLE
  335. The response includes the user who submitted the request (`user2`), including
  336. the `jwt_role1` role that you mapped to this user in the JWT realm:
  337. [source,sh]
  338. ----
  339. {"username":"user2","roles":["jwt_role1"],"full_name":null,"email":"user2@something.example.com",
  340. "metadata":{"jwt_claim_email":"user2@something.example.com","jwt_claim_aud":["es01","es02","es03"],
  341. "jwt_claim_sub":"user2","jwt_claim_iss":"my-issuer"},"enabled":true,"authentication_realm":
  342. {"name":"jwt2","type":"jwt"},"lookup_realm":{"name":"jwt2","type":"jwt"},"authentication_type":"realm"}
  343. %
  344. ----
  345. If you want to specify a request as the `run_as` user, include the
  346. the `es-security-runas-user` header with the name of the user that you
  347. want to submit requests as. The following request uses the `user123_runas` user:
  348. [source,sh]
  349. ----
  350. curl -s -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiZXMwMSIsImVzMDIiLCJlczAzIl0sInN1YiI6InVzZXIyIiwiaXNzIjoibXktaXNzdWVyIiwiZXhwIjo0MDcwOTA4ODAwLCJpYXQiOjk0NjY4NDgwMCwiZW1haWwiOiJ1c2VyMkBzb21ldGhpbmcuZXhhbXBsZS5jb20ifQ.UgO_9w--EoRyUKcWM5xh9SimTfMzl1aVu6ZBsRWhxQA" -H "ES-Client-Authentication: sharedsecret test-secret" -H "es-security-runas-user: user123_runas" https://localhost:9200/_security/_authenticate
  351. ----
  352. // NOTCONSOLE
  353. In the response, you'll see that the `user123_runas` user submitted the request,
  354. and {es} used the `jwt_role1` role:
  355. [source,sh]
  356. ----
  357. {"username":"user123_runas","roles":["jwt_role1"],"full_name":null,"email":null,"metadata":{},
  358. "enabled":true,"authentication_realm":{"name":"jwt2","type":"jwt"},"lookup_realm":{"name":"native",
  359. "type":"native"},"authentication_type":"realm"}%
  360. ----
  361. [[hmac-oidc-example]]
  362. ==== Authorizing to the JWT realm with an OIDC HMAC key
  363. The following settings are for a JWT issuer, {es}, and a client of {es}. The
  364. example HMAC key is in an OIDC format that's compatible with HMAC. The key bytes
  365. are the UTF-8 encoding of the UNICODE characters.
  366. IMPORTANT: HMAC UTF-8 keys need to be longer than HMAC random byte keys to
  367. achieve the same key strength.
  368. [[hmac-oidc-example-jwt-issuer]]
  369. ===== JWT issuer
  370. The following values are for the bespoke JWT issuer.
  371. [source,js]
  372. ----
  373. Issuer: iss8
  374. Audiences: aud8
  375. Algorithms: HS256
  376. HMAC OIDC: hmac-oidc-key-string-for-hs256-algorithm
  377. ----
  378. // NOTCONSOLE
  379. [[hmac-oidc-example-jwt-realm]]
  380. ===== JWT realm settings
  381. To define a JWT realm, add the following realm settings to `elasticsearch.yml`.
  382. [source,yaml]
  383. ----
  384. xpack.security.authc.realms.jwt.jwt8.order: 8 <1>
  385. xpack.security.authc.realms.jwt.jwt8.allowed_issuer: iss8
  386. xpack.security.authc.realms.jwt.jwt8.allowed_audiences: [aud8]
  387. xpack.security.authc.realms.jwt.jwt8.allowed_signature_algorithms: [HS256]
  388. xpack.security.authc.realms.jwt.jwt8.claims.principal: sub
  389. xpack.security.authc.realms.jwt.jwt8.client_authentication.type: shared_secret
  390. ----
  391. <1> In {ecloud}, the realm order starts at `2`. `0` and `1` are reserved in the
  392. realm chain on {ecloud}.
  393. ===== JWT realm secure settings
  394. After defining the realm settings, use the
  395. {ref}/elasticsearch-keystore.html[`elasticsearch-keystore`] tool to add the
  396. following secure settings to the {es} keystore. In {ecloud}, you define settings
  397. for the {es} keystore under **Security** in your deployment.
  398. [source,yaml]
  399. ----
  400. xpack.security.authc.realms.jwt.jwt8.hmac_key: hmac-oidc-key-string-for-hs256-algorithm
  401. xpack.security.authc.realms.jwt.jwt8.client_authentication.shared_secret: client-shared-secret-string
  402. ----
  403. ===== JWT realm role mapping rule
  404. The following request creates role mappings for {es} in the `jwt8` realm for
  405. the user `principalname1`:
  406. [source,console]
  407. ----
  408. PUT /_security/role_mapping/jwt8_users?refresh=true
  409. {
  410. "roles" : [ "user" ],
  411. "rules" : { "all" : [
  412. { "field": { "realm.name": "jwt8" } },
  413. { "field": { "username": "principalname1" } }
  414. ] },
  415. "enabled": true
  416. }
  417. ----
  418. [[hmac-oidc-example-request-headers]]
  419. ===== Request headers
  420. The following header settings are for an {es} client.
  421. [source,js]
  422. ----
  423. Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3M4IiwiYXVkIjoiYXVkOCIsInN1YiI6InNlY3VyaXR5X3Rlc3RfdXNlciIsImV4cCI6NDA3MDkwODgwMCwiaWF0Ijo5NDY2ODQ4MDB9.UnnFmsoFKfNmKMsVoDQmKI_3-j95PCaKdgqqau3jPMY
  424. ES-Client-Authentication: SharedSecret client-shared-secret-string
  425. ----
  426. // NOTCONSOLE
  427. You can use this header in a `curl` request to make an authenticated call to
  428. {es}. Both the bearer token and the client authorization token must be
  429. specified as separate headers with the `-H` option:
  430. [source,sh]
  431. ----
  432. curl -s -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3M4IiwiYXVkIjoiYXVkOCIsInN1YiI6InNlY3VyaXR5X3Rlc3RfdXNlciIsImV4cCI6NDA3MDkwODgwMCwiaWF0Ijo5NDY2ODQ4MDB9.UnnFmsoFKfNmKMsVoDQmKI_3-j95PCaKdgqqau3jPMY" -H "ES-Client-Authentication: SharedSecret client-shared-secret-string" https://localhost:9200/_security/_authenticate
  433. ----
  434. // NOTCONSOLE
  435. If you used role mapping in the JWT realm, the response includes the user's
  436. `username`, their `roles`, metadata about the user, and the details about the
  437. JWT realm itself.
  438. [source,sh]
  439. ----
  440. {"username":"user2","roles":["jwt_role1"],"full_name":null,"email":"user2@something.example.com",
  441. "metadata":{"jwt_claim_email":"user2@something.example.com","jwt_claim_aud":["es01","es02","es03"],
  442. "jwt_claim_sub":"user2","jwt_claim_iss":"my-issuer"},"enabled":true,"authentication_realm":
  443. {"name":"jwt2","type":"jwt"},"lookup_realm":{"name":"jwt2","type":"jwt"},"authentication_type":"realm"}
  444. %
  445. ----