Skip to content

Commit 97073f4

Browse files
committed
Use specific purpose when using machine key to avoid derived key caching on FE
1 parent efb55da commit 97073f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/WebJobs.Script.Scaling/ScaleUtils.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ namespace Microsoft.Azure.WebJobs.Script.Scaling
1414
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "By design")]
1515
public static class ScaleUtils
1616
{
17+
public const string Purpose = "ScaleManager";
18+
1719
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "By design")]
1820
public static bool WorkerEquals(IWorkerInfo src, IWorkerInfo dst)
1921
{
@@ -87,14 +89,14 @@ public static string ToDisplayString(this IEnumerable<string> values)
8789
public static string GetToken(DateTime expiredUtc)
8890
{
8991
var bytes = BitConverter.GetBytes(expiredUtc.Ticks);
90-
var encrypted = MachineKey.Protect(bytes);
92+
var encrypted = MachineKey.Protect(bytes, Purpose);
9193
return Convert.ToBase64String(encrypted);
9294
}
9395

9496
public static void ValidateToken(string token)
9597
{
9698
var encrypted = Convert.FromBase64String(token);
97-
var bytes = MachineKey.Unprotect(encrypted);
99+
var bytes = MachineKey.Unprotect(encrypted, Purpose);
98100
var ticks = BitConverter.ToInt64(bytes, 0);
99101
var expiredUtc = new DateTime(ticks, DateTimeKind.Utc);
100102

0 commit comments

Comments
 (0)