Skip to content

Commit

Permalink
add params to CreateJwtToken
Browse files Browse the repository at this point in the history
  • Loading branch information
hoseinzadehashraf committed Sep 28, 2023
1 parent ba03956 commit b511f90
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Olive.Mvc.Security/OliveSecurityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ public static ClaimsIdentity ToClaimsIdentity(this ILoginInfo @this)
return new ClaimsIdentity(claims, "Olive");
}

public static string CreateJwtToken(this ILoginInfo @this)
public static string CreateJwtToken(this ILoginInfo @this, IEnumerable<Claim> additionalClaims = null, bool remember = false)
{
var securityKey = OAuth.GetJwtSecurityKey();

var identity = @this.ToClaimsIdentity();
identity.AddClaims(additionalClaims.OrEmpty());
identity.AddClaim(new Claim(ClaimTypes.IsPersistent, remember.ToString()));

var descriptor = new SecurityTokenDescriptor
{
Subject = @this.ToClaimsIdentity(),
Subject = identity,
Issuer = Context.Current.Request().RootUrl(),
Audience = Context.Current.Request().RootUrl(),
Expires = DateTime.UtcNow.Add(@this.Timeout ?? DistantFuture),
Expand Down

0 comments on commit b511f90

Please sign in to comment.