marcominerva / SimpleAuthentication

A library to easily integrate Authentication in ASP.NET Core projects.
MIT License
220 stars 26 forks source link

Union extension method on IList<Claim> type #94

Open N1K0232 opened 1 year ago

N1K0232 commented 1 year ago

I had an idea for a new extension method that I started using in my projects After sign-in task, I create a collection of claims. Usually this collection ends with the list of the roles, the user has.

Since a Jwt bearer token allows the user to have more values for the same type, my idea is to create an extension method that can add a list of string values for a given claim type

Here my example: public static void Union(this IList claims, string claimType, IEnumerable values)

Could this approach be possible to avoid code duplication each time?

marcominerva commented 1 year ago

Perhaps the correct signature for your proposal should be:

public static void Union(this IList<Claim> claims, string claimType, IEnumerable values);

Is it correct?

N1K0232 commented 1 year ago

Yes correct. I meant that one

marcominerva commented 1 year ago

So, what about making a pull request? ;)

N1K0232 commented 1 year ago

Ok. I can try. Thank you! :)