Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to add several claims #210

Merged
merged 5 commits into from
Aug 17, 2019
Merged

Add method to add several claims #210

merged 5 commits into from
Aug 17, 2019

Conversation

pBouillon
Copy link
Contributor

@pBouillon pBouillon commented Aug 17, 2019

The "why"

While using this library in my company, we would have liked to use the builder to add several claims in a more readable way.

We would have liked to be allowed to do something such as:

var token = new JwtBuilder()
      .WithAlgorithm(new HMACSHA256Algorithm())
      .WithSecret(secret)
      .AddClaims({
          "my-claim": "my-value",
          "my-claim-2": "my-value-2"
      })
     .Build();

PR content

I just added a method AddClaims allowing the user to pass a IDictionnary of string: object in it and add each of its key as a new claim and each of its value as claim value.

@abatishchev
Copy link
Member

Hi! Thanks for the contribution! I'm happy to merge it.
Can you please to add simple test, as well as bump the version in Jwt.csproj?

@pBouillon
Copy link
Contributor Author

Sure thing, there it is !

@pBouillon
Copy link
Contributor Author

Hum, any idea why the restoration failed @abatishchev ?

@abatishchev
Copy link
Member

You've bumped the wrong thing, Json.Net version instead of Jwt.Net own version :)

@abatishchev
Copy link
Member

Fixed that.
Waiting for the gated build to succeed. And we're good to go.
Thanks again for the change and quick turnaround too!

@abatishchev abatishchev merged commit a1eb810 into jwt-dotnet:master Aug 17, 2019
@abatishchev
Copy link
Member

abatishchev commented Aug 17, 2019

Pushed to NuGet as 5.2.3 (might take several minutes to get indexed and appear publicly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants