question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suport Array of String for Audience

See original GitHub issue

From the JWT specification, the Audience should accept a array of strings. Whould be nice a methot setAudience that accept a array of Strings and put this attribute as array on JWT As a workaround, I’m setting this as a claim attribute:

String[] aud = { "aud1", "aud2" };
Jwts.builder().claim("aud", aud);
...

Generated payload:

{
  "iss": "issuer",
  "aud": [
    "aud1",
    "aud2"
  ],
  "iat": 1443461450
}

From https://tools.ietf.org/html/rfc7519#section-4.1.3

4.1.3.  "aud" (Audience) Claim

   The "aud" (audience) claim identifies the recipients that the JWT is
   intended for.  Each principal intended to process the JWT MUST
   identify itself with a value in the audience claim.  If the principal
   processing the claim does not identify itself with a value in the
   "aud" claim when this claim is present, then the JWT MUST be
   rejected.  In the general case, the "aud" value is an array of case-
   sensitive strings, each containing a StringOrURI value.  In the
   special case when the JWT has one audience, the "aud" value MAY be a
   single case-sensitive string containing a StringOrURI value.  The
   interpretation of audience values is generally application specific.
   Use of this claim is OPTIONAL.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jebbenchcommented, Jan 22, 2016

It would be good if the requireAudience method could also work with arrays.

0reactions
ricvealcommented, Mar 17, 2018

I’ve made a PR #238 that, if it’s accepted, would add support for string arrays in audience attribute without breaks the current functionality. The idea behind the PR is to handle both a simple String and a String array.

Read more comments on GitHub >

github_iconTop Results From Across the Web

array of strings contains a string value matching this regex
It would be a great help to be able to use regex for condition when working with arrays of strings because of several...
Read more >
Working with Collections | Defining and Using Classes
Describes how to use collections, which are arrays or lists of elements, all of the same type. The elements can be literal values...
Read more >
Field Data Types - Iterable Support Center
Each field in a user profile or event in Iterable has a value type: string, date, integer, long, double, or boolean. Iterable also...
Read more >
Array - Sanity.io
Schema type for arrays of other types. ... This option only works if the array contains strings. If set to grid it will...
Read more >
Helpers - Laravel - The PHP Framework For Web Artisans
Using this method's second argument, you may also specify the joining string for the final element of the array: use Illuminate\Support\Arr;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found