Skip to content

Commit 391cb1b

Browse files
Refactors JWT creation
1 parent c8c6309 commit 391cb1b

File tree

4 files changed

+3
-44
lines changed

4 files changed

+3
-44
lines changed

dev-proxy/Jwt/Jwt.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

dev-proxy/Jwt/JwtCreatorOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static JwtCreatorOptions Create(JwtOptions options)
2727
Scopes = options.Scopes ?? [],
2828
Claims = options.Claims ?? [],
2929
NotBefore = DateTime.UtcNow,
30-
ExpiresOn = DateTime.UtcNow.AddMinutes(options.ValidFor == 0 ? 60 : options.ValidFor)
30+
ExpiresOn = DateTime.UtcNow.AddMinutes(options.ValidFor ?? 60)
3131
};
3232
}
3333
}

dev-proxy/Jwt/JwtOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public class JwtOptions
1111
public IEnumerable<string>? Roles { get; set; }
1212
public IEnumerable<string>? Scopes { get; set; }
1313
public Dictionary<string, string>? Claims { get; set; }
14-
public double ValidFor { get; set; }
14+
public double? ValidFor { get; set; }
1515
}

dev-proxy/Jwt/JwtTokenGenerator.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ internal static string CreateToken(JwtOptions jwtOptions)
1818
);
1919

2020
var jwtToken = jwtIssuer.CreateSecurityToken(options);
21-
22-
var jwt = Jwt.Create(
23-
options.Scheme,
24-
jwtToken,
25-
new JwtSecurityTokenHandler().WriteToken(jwtToken),
26-
options.Scopes,
27-
options.Roles,
28-
options.Claims
29-
);
30-
31-
return jwt.Token;
21+
return new JwtSecurityTokenHandler().WriteToken(jwtToken);
3222
}
3323
}

0 commit comments

Comments
 (0)