Git repo tokens for the security service
Mar 14, 2017Matt Cooper

Summary
This post explains the internal algorithm used by VSTS to generate security tokens for Git resources, particularly branches. It details how case-sensitive Git ref names (e.g., 'master') are encoded into a case-insensitive string format (e.g., 'refs/heads/6d0061007300740065007200') to be used with the VSTS security REST endpoint and TFSSecurity.exe. The explanation covers the token structure (repoV2, project ID, repo ID, resource path) and the UTF-16 little-endian encoding of characters for case-insensitive transport. Code snippets in C# and Python are provided to illustrate the encoding algorithm.