mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
[PM-5645] Cosmos DB Grant Storage (#3634)
* table storage grants * simple shard on storage accounts * use is not * cosmos grant repo * remove single storage connection string * some fixes to dapper grant repo * pattern matching * add fallback to base PersistedGrantStore * service collection extension cleanup * cleanup * remove unused Id * empty string rowkey * fix sharding method logic * ttl for cosmos * make ttl an int * fixes to cosmos implementation * fix partition key values * catch notfound exceptions * indenting * update grantitem with custom serialization * use new transform helpers * grantloader perf test tool * ref * remove grant loader project * remove table storage implementation * remove table storage stuff * all redis fallback to build to null * revert sln file change * EOF new line * remove trailing comma * lint fixes * add grant to names * move cosmos serilaizer to utils * add some .net 8 keyed service comments * EnableContentResponseOnWrite * Fix type in EF grant repository
This commit is contained in:
@ -338,16 +338,50 @@ public static class CoreHelpers
|
||||
return Encoding.UTF8.GetString(Base64UrlDecode(input));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encodes a Base64 URL formatted string.
|
||||
/// </summary>
|
||||
/// <param name="input">Byte data</param>
|
||||
/// <returns>Base64 URL formatted string</returns>
|
||||
public static string Base64UrlEncode(byte[] input)
|
||||
{
|
||||
var output = Convert.ToBase64String(input)
|
||||
// Standard base64 encoder
|
||||
var standardB64 = Convert.ToBase64String(input);
|
||||
return TransformToBase64Url(standardB64);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a Base64 standard formatted string to a Base64 URL formatted string.
|
||||
/// </summary>
|
||||
/// <param name="input">Base64 standard formatted string</param>
|
||||
/// <returns>Base64 URL formatted string</returns>
|
||||
public static string TransformToBase64Url(string input)
|
||||
{
|
||||
var output = input
|
||||
.Replace('+', '-')
|
||||
.Replace('/', '_')
|
||||
.Replace("=", string.Empty);
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes a Base64 URL formatted string.
|
||||
/// </summary>
|
||||
/// <param name="input">Base64 URL formatted string</param>
|
||||
/// <returns>Data as bytes</returns>
|
||||
public static byte[] Base64UrlDecode(string input)
|
||||
{
|
||||
var standardB64 = TransformFromBase64Url(input);
|
||||
// Standard base64 decoder
|
||||
return Convert.FromBase64String(standardB64);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a Base64 URL formatted string to a Base64 standard formatted string.
|
||||
/// </summary>
|
||||
/// <param name="input">Base64 URL formatted string</param>
|
||||
/// <returns>Base64 standard formatted string</returns>
|
||||
public static string TransformFromBase64Url(string input)
|
||||
{
|
||||
var output = input;
|
||||
// 62nd char of encoding
|
||||
@ -370,8 +404,8 @@ public static class CoreHelpers
|
||||
throw new InvalidOperationException("Illegal base64url string!");
|
||||
}
|
||||
|
||||
// Standard base64 decoder
|
||||
return Convert.FromBase64String(output);
|
||||
// Standard base64 string output
|
||||
return output;
|
||||
}
|
||||
|
||||
public static string PunyEncode(string text)
|
||||
|
Reference in New Issue
Block a user